From 0de9b824c4f35a8704c0aa6b4e301634295a2fe4 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Fri, 20 Mar 2015 23:42:06 -0700 Subject: [PATCH 01/25] adding first cut on modularized version --- solution/movieplex7-ear/batch/pom.xml | 23 +++ .../javaee7/movieplex7/batch/SalesBean.java | 76 ++++++++ .../movieplex7/batch/SalesProcessor.java | 65 +++++++ .../javaee7/movieplex7/batch/SalesReader.java | 81 +++++++++ .../javaee7/movieplex7/batch/SalesWriter.java | 68 ++++++++ .../META-INF/batch-jobs/eod-sales.xml | 55 ++++++ .../src/main/resources/META-INF/sales.csv | 20 +++ solution/movieplex7-ear/booking/pom.xml | 25 +++ .../javaee7/movieplex7/booking/Booking.java | 120 +++++++++++++ solution/movieplex7-ear/chat/pom.xml | 15 ++ .../javaee7/movieplex7/chat/ChatServer.java | 77 +++++++++ solution/movieplex7-ear/client/pom.xml | 24 +++ .../movieplex7/client/MovieBackingBean.java | 80 +++++++++ .../movieplex7/client/MovieClientBean.java | 131 ++++++++++++++ solution/movieplex7-ear/ear/pom.xml | 131 ++++++++++++++ solution/movieplex7-ear/entities/pom.xml | 13 ++ .../javaee7/movieplex7/entities/Movie.java | 155 +++++++++++++++++ .../javaee7/movieplex7/entities/Sales.java | 143 +++++++++++++++ .../movieplex7/entities/ShowTiming.java | 163 ++++++++++++++++++ .../javaee7/movieplex7/entities/Theater.java | 139 +++++++++++++++ .../javaee7/movieplex7/entities/Timeslot.java | 158 +++++++++++++++++ .../src/main/resources/META-INF/create.sql | 10 ++ .../src/main/resources/META-INF/drop.sql | 6 + .../src/main/resources/META-INF/load.sql | 67 +++++++ .../main/resources/META-INF/persistence.xml | 16 ++ solution/movieplex7-ear/json/pom.xml | 23 +++ .../javaee7/movieplex7/json/MovieReader.java | 100 +++++++++++ .../javaee7/movieplex7/json/MovieWriter.java | 91 ++++++++++ solution/movieplex7-ear/nb-configuration.xml | 18 ++ solution/movieplex7-ear/points/pom.xml | 15 ++ .../movieplex7/points/ReceivePointsBean.java | 95 ++++++++++ .../movieplex7/points/SendPointsBean.java | 82 +++++++++ solution/movieplex7-ear/pom.xml | 65 +++++++ solution/movieplex7-ear/rest/pom.xml | 23 +++ .../movieplex7/rest/AbstractFacade.java | 97 +++++++++++ .../movieplex7/rest/ApplicationConfig.java | 72 ++++++++ .../movieplex7/rest/MovieFacadeREST.java | 123 +++++++++++++ .../movieplex7/rest/SalesFacadeREST.java | 124 +++++++++++++ .../movieplex7/rest/ShowTimingFacadeREST.java | 123 +++++++++++++ .../movieplex7/rest/TheaterFacadeREST.java | 123 +++++++++++++ .../movieplex7/rest/TimeslotFacadeREST.java | 123 +++++++++++++ .../movieplex7-ear/web/nb-configuration.xml | 19 ++ solution/movieplex7-ear/web/pom.xml | 81 +++++++++ .../src/main/webapp/WEB-INF/faces-config.xml | 5 + .../web/src/main/webapp/WEB-INF/jboss-web.xml | 4 + .../src/main/webapp/WEB-INF/template.xhtml | 92 ++++++++++ .../web/src/main/webapp/WEB-INF/web.xml | 64 +++++++ .../web/src/main/webapp/batch/sales.xhtml | 79 +++++++++ .../src/main/webapp/booking/booking-flow.xml | 56 ++++++ .../web/src/main/webapp/booking/booking.xhtml | 71 ++++++++ .../web/src/main/webapp/booking/confirm.xhtml | 82 +++++++++ .../web/src/main/webapp/booking/print.xhtml | 68 ++++++++ .../src/main/webapp/booking/showtimes.xhtml | 30 ++++ .../web/src/main/webapp/chat/chatroom.xhtml | 85 +++++++++ .../web/src/main/webapp/chat/websocket.js | 97 +++++++++++ .../web/src/main/webapp/client/addmovie.xhtml | 77 +++++++++ .../web/src/main/webapp/client/movie.xhtml | 77 +++++++++ .../web/src/main/webapp/client/movies.xhtml | 73 ++++++++ .../web/src/main/webapp/index.html | 10 ++ .../web/src/main/webapp/index.xhtml | 58 +++++++ .../web/src/main/webapp/points/points.xhtml | 69 ++++++++ .../main/webapp/resources/css/cssLayout.css | 61 +++++++ .../src/main/webapp/resources/css/default.css | 29 ++++ 63 files changed, 4445 insertions(+) create mode 100644 solution/movieplex7-ear/batch/pom.xml create mode 100644 solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesBean.java create mode 100644 solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesProcessor.java create mode 100644 solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesReader.java create mode 100644 solution/movieplex7-ear/batch/src/main/java/org/javaee7/movieplex7/batch/SalesWriter.java create mode 100644 solution/movieplex7-ear/batch/src/main/resources/META-INF/batch-jobs/eod-sales.xml create mode 100644 solution/movieplex7-ear/batch/src/main/resources/META-INF/sales.csv create mode 100644 solution/movieplex7-ear/booking/pom.xml create mode 100644 solution/movieplex7-ear/booking/src/main/java/org/javaee7/movieplex7/booking/Booking.java create mode 100644 solution/movieplex7-ear/chat/pom.xml create mode 100644 solution/movieplex7-ear/chat/src/main/java/org/javaee7/movieplex7/chat/ChatServer.java create mode 100644 solution/movieplex7-ear/client/pom.xml create mode 100644 solution/movieplex7-ear/client/src/main/java/org/javaee7/movieplex7/client/MovieBackingBean.java create mode 100644 solution/movieplex7-ear/client/src/main/java/org/javaee7/movieplex7/client/MovieClientBean.java create mode 100644 solution/movieplex7-ear/ear/pom.xml create mode 100644 solution/movieplex7-ear/entities/pom.xml create mode 100644 solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Movie.java create mode 100644 solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Sales.java create mode 100644 solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/ShowTiming.java create mode 100644 solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Theater.java create mode 100644 solution/movieplex7-ear/entities/src/main/java/org/javaee7/movieplex7/entities/Timeslot.java create mode 100644 solution/movieplex7-ear/entities/src/main/resources/META-INF/create.sql create mode 100644 solution/movieplex7-ear/entities/src/main/resources/META-INF/drop.sql create mode 100644 solution/movieplex7-ear/entities/src/main/resources/META-INF/load.sql create mode 100644 solution/movieplex7-ear/entities/src/main/resources/META-INF/persistence.xml create mode 100644 solution/movieplex7-ear/json/pom.xml create mode 100644 solution/movieplex7-ear/json/src/main/java/org/javaee7/movieplex7/json/MovieReader.java create mode 100644 solution/movieplex7-ear/json/src/main/java/org/javaee7/movieplex7/json/MovieWriter.java create mode 100644 solution/movieplex7-ear/nb-configuration.xml create mode 100644 solution/movieplex7-ear/points/pom.xml create mode 100644 solution/movieplex7-ear/points/src/main/java/org/javaee7/movieplex7/points/ReceivePointsBean.java create mode 100644 solution/movieplex7-ear/points/src/main/java/org/javaee7/movieplex7/points/SendPointsBean.java create mode 100644 solution/movieplex7-ear/pom.xml create mode 100644 solution/movieplex7-ear/rest/pom.xml create mode 100644 solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/AbstractFacade.java create mode 100644 solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/ApplicationConfig.java create mode 100644 solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/MovieFacadeREST.java create mode 100644 solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/SalesFacadeREST.java create mode 100644 solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/ShowTimingFacadeREST.java create mode 100644 solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/TheaterFacadeREST.java create mode 100644 solution/movieplex7-ear/rest/src/main/java/org/javaee7/movieplex7/rest/TimeslotFacadeREST.java create mode 100644 solution/movieplex7-ear/web/nb-configuration.xml create mode 100644 solution/movieplex7-ear/web/pom.xml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/WEB-INF/faces-config.xml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/WEB-INF/jboss-web.xml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/WEB-INF/template.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/WEB-INF/web.xml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/batch/sales.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/booking/booking-flow.xml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/booking/booking.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/booking/confirm.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/booking/print.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/booking/showtimes.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/chat/chatroom.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/chat/websocket.js create mode 100644 solution/movieplex7-ear/web/src/main/webapp/client/addmovie.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/client/movie.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/client/movies.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/index.html create mode 100644 solution/movieplex7-ear/web/src/main/webapp/index.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/points/points.xhtml create mode 100644 solution/movieplex7-ear/web/src/main/webapp/resources/css/cssLayout.css create mode 100644 solution/movieplex7-ear/web/src/main/webapp/resources/css/default.css diff --git a/solution/movieplex7-ear/batch/pom.xml b/solution/movieplex7-ear/batch/pom.xml new file mode 100644 index 0000000..07f32be --- /dev/null +++ b/solution/movieplex7-ear/batch/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.javaee7 + movieplex7 + 1.0-SNAPSHOT + + org.javaee7.movieplex7 + batch + jar + + UTF-8 + + + + + org.javaee7.movieplex7 + entities + 1.0-SNAPSHOT + + + \ 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/booking/pom.xml b/solution/movieplex7-ear/booking/pom.xml new file mode 100644 index 0000000..008cf7d --- /dev/null +++ b/solution/movieplex7-ear/booking/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + + org.javaee7 + movieplex7 + 1.0-SNAPSHOT + + org.javaee7.movieplex7 + booking + jar + + + + org.javaee7.movieplex7 + entities + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + json + 1.0-SNAPSHOT + + + \ 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/chat/pom.xml b/solution/movieplex7-ear/chat/pom.xml new file mode 100644 index 0000000..32f9501 --- /dev/null +++ b/solution/movieplex7-ear/chat/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + org.javaee7 + movieplex7 + 1.0-SNAPSHOT + + org.javaee7.movieplex7 + chat + jar + + UTF-8 + + \ 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/client/pom.xml b/solution/movieplex7-ear/client/pom.xml new file mode 100644 index 0000000..27e31a0 --- /dev/null +++ b/solution/movieplex7-ear/client/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + org.javaee7 + movieplex7 + 1.0-SNAPSHOT + + org.javaee7.movieplex7 + client + jar + + + org.javaee7.movieplex7 + entities + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + json + 1.0-SNAPSHOT + + + \ 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..3a154e4 --- /dev/null +++ b/solution/movieplex7-ear/client/src/main/java/org/javaee7/movieplex7/client/MovieClientBean.java @@ -0,0 +1,131 @@ +/* + * 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() + + "/" + + httpServletRequest.getContextPath() + + "/webresources/movie/"); + } + + @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/ear/pom.xml b/solution/movieplex7-ear/ear/pom.xml new file mode 100644 index 0000000..0568796 --- /dev/null +++ b/solution/movieplex7-ear/ear/pom.xml @@ -0,0 +1,131 @@ + + + 4.0.0 + + movieplex7 + org.javaee7 + 1.0-SNAPSHOT + + org.javaee7.movieplex7 + ear + 1.0-SNAPSHOT + ear + + + + org.javaee7.movieplex7 + web + 1.0-SNAPSHOT + war + + + org.javaee7.movieplex7 + batch + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + booking + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + chat + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + client + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + entities + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + json + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + points + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + rest + 1.0-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-ear-plugin + 2.10 + + + + + org.javaee7.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 + + + org.javaee7.movieplex7 + points + + + org.javaee7.movieplex7 + rest + + + + + + org.wildfly.plugins + wildfly-maven-plugin + 1.0.2.Final + + false + + + + + \ 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..c4b77b1 --- /dev/null +++ b/solution/movieplex7-ear/entities/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + + org.javaee7 + movieplex7 + 1.0-SNAPSHOT + + org.javaee7.movieplex7 + entities + jar + 1.0-SNAPSHOT + \ 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..2e744b1 --- /dev/null +++ b/solution/movieplex7-ear/json/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.javaee7 + movieplex7 + 1.0-SNAPSHOT + + org.javaee7.movieplex7 + json + jar + + UTF-8 + + + + + org.javaee7.movieplex7 + entities + 1.0-SNAPSHOT + + + \ 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..b40f06e --- /dev/null +++ b/solution/movieplex7-ear/points/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + org.javaee7 + movieplex7 + 1.0-SNAPSHOT + + org.javaee7.movieplex7 + points + jar + + UTF-8 + + \ 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/pom.xml b/solution/movieplex7-ear/pom.xml new file mode 100644 index 0000000..6db059f --- /dev/null +++ b/solution/movieplex7-ear/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + org.javaee7 + movieplex7 + 1.0-SNAPSHOT + pom + + + booking + batch + chat + json + points + rest + entities + client + web + ear + + + Java EE 7 Hands-on Lab Solution - MSA + + + + + javax + javaee-api + 7.0 + 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 + + + + + + \ No newline at end of file diff --git a/solution/movieplex7-ear/rest/pom.xml b/solution/movieplex7-ear/rest/pom.xml new file mode 100644 index 0000000..11ef707 --- /dev/null +++ b/solution/movieplex7-ear/rest/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.javaee7 + movieplex7 + 1.0-SNAPSHOT + + org.javaee7.movieplex7 + rest + jar + + UTF-8 + + + + + org.javaee7.movieplex7 + entities + 1.0-SNAPSHOT + + + \ 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..bd3e38a --- /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/nb-configuration.xml b/solution/movieplex7-ear/web/nb-configuration.xml new file mode 100644 index 0000000..7577ef7 --- /dev/null +++ b/solution/movieplex7-ear/web/nb-configuration.xml @@ -0,0 +1,19 @@ + + + + + + 1.7-web + WildFly + + diff --git a/solution/movieplex7-ear/web/pom.xml b/solution/movieplex7-ear/web/pom.xml new file mode 100644 index 0000000..47faeaa --- /dev/null +++ b/solution/movieplex7-ear/web/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + + movieplex7 + org.javaee7 + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + web + 1.0-SNAPSHOT + war + + movieplex7 + + + ${project.build.directory}/endorsed + UTF-8 + + + + + javax + javaee-web-api + 7.0 + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + ${endorsed.dir} + + + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + false + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + validate + + copy + + + ${endorsed.dir} + true + + + javax + javaee-endorsed-api + 7.0 + jar + + + + + + + + + + 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/jboss-web.xml b/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/jboss-web.xml new file mode 100644 index 0000000..d1352c4 --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/jboss-web.xml @@ -0,0 +1,4 @@ + + + /movieplex7 + diff --git a/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/template.xhtml b/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/template.xhtml new file mode 100644 index 0000000..dc0fc21 --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/template.xhtml @@ -0,0 +1,92 @@ + + + + + + + + + + + Movieplex 7 + + + + + +
+ + +

+
+ +
+
+
+
+ + + Book a movie +

Chat Room +

Movies +

Sales +

Points + + +

+
+ Content +
+
+
+ + 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/batch/sales.xhtml b/solution/movieplex7-ear/web/src/main/webapp/batch/sales.xhtml new file mode 100644 index 0000000..8cde586 --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/batch/sales.xhtml @@ -0,0 +1,79 @@ + + + + + + + + + + +

Movie Sales

+ + + + + + + #{s.id} + + + + + + #{s.amount} + + + + + + +
+ +
+ + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/booking/booking-flow.xml b/solution/movieplex7-ear/web/src/main/webapp/booking/booking-flow.xml new file mode 100644 index 0000000..2d9efbd --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/booking/booking-flow.xml @@ -0,0 +1,56 @@ + + + + + + + + /index + + + + \ No newline at end of file diff --git a/solution/movieplex7-ear/web/src/main/webapp/booking/booking.xhtml b/solution/movieplex7-ear/web/src/main/webapp/booking/booking.xhtml new file mode 100644 index 0000000..00dfd6a --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/booking/booking.xhtml @@ -0,0 +1,71 @@ + + + + + + + + + + + +

Pick a movie

+ + + + + + + + + + +
+ +
+ + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/booking/confirm.xhtml b/solution/movieplex7-ear/web/src/main/webapp/booking/confirm.xhtml new file mode 100644 index 0000000..908ae5a --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/booking/confirm.xhtml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + +

No theater found, choose a different time

+ + Movie name: #{booking.movieName}

+ Starts at: #{booking.startTime}

+

+ + + +

Confirm ?

+ + + Movie name: #{booking.movieName}

+ Starts at: #{booking.startTime}

+ Theater: #{booking.theater}

+

+

+
+ +
+ +
+ +
+ + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/booking/print.xhtml b/solution/movieplex7-ear/web/src/main/webapp/booking/print.xhtml new file mode 100644 index 0000000..fcaa28c --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/booking/print.xhtml @@ -0,0 +1,68 @@ + + + + + + + + + + + +

Reservation Confirmed

+ + + Movie name: #{booking.movieName}

+ Starts at: #{booking.startTime}

+ Theater: #{booking.theater}

+ +

+
+
+ +
+ + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/booking/showtimes.xhtml b/solution/movieplex7-ear/web/src/main/webapp/booking/showtimes.xhtml new file mode 100644 index 0000000..4373d54 --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/booking/showtimes.xhtml @@ -0,0 +1,30 @@ + + + + + + + + + +

Show Timings for #{booking.movieName}

+ + + + + + + + + + +
+ +
+ + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/chat/chatroom.xhtml b/solution/movieplex7-ear/web/src/main/webapp/chat/chatroom.xhtml new file mode 100644 index 0000000..99e70df --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/chat/chatroom.xhtml @@ -0,0 +1,85 @@ + + + + + + + + + + +
+ + + + + + + + + +
+ Chat Log
+ +
+ Users
+ +
+ + +

+ +

+ +
+
+ + +
+ +
+ + + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/chat/websocket.js b/solution/movieplex7-ear/web/src/main/webapp/chat/websocket.js new file mode 100644 index 0000000..b2d0456 --- /dev/null +++ b/solution/movieplex7-ear/web/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/web/src/main/webapp/client/addmovie.xhtml b/solution/movieplex7-ear/web/src/main/webapp/client/addmovie.xhtml new file mode 100644 index 0000000..b455b2e --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/client/addmovie.xhtml @@ -0,0 +1,77 @@ + + + + + + + + + + +

Add a New Movie

+ + + + + + + + + + + + + + + +
Movie Id:
Movie Name:
Movie Actors:
+ +
+
+ +
+ + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/client/movie.xhtml b/solution/movieplex7-ear/web/src/main/webapp/client/movie.xhtml new file mode 100644 index 0000000..1a0c3a8 --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/client/movie.xhtml @@ -0,0 +1,77 @@ + + + + + + + + + + +

Movie Details

+ + + + + + + + + + + + + + + +
Movie Id:#{movieClientBean.movie.id}
Movie Name:#{movieClientBean.movie.name}
Movie Actors:#{movieClientBean.movie.actors}
+ +
+
+ +
+ + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/client/movies.xhtml b/solution/movieplex7-ear/web/src/main/webapp/client/movies.xhtml new file mode 100644 index 0000000..7f812e2 --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/client/movies.xhtml @@ -0,0 +1,73 @@ + + + + + + + + + + + +

List of Movies

+ + + + + + + + + + + +
+ +
+ + + 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 + + + +

Hello World!

+ + diff --git a/solution/movieplex7-ear/web/src/main/webapp/index.xhtml b/solution/movieplex7-ear/web/src/main/webapp/index.xhtml new file mode 100644 index 0000000..e5362b3 --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/index.xhtml @@ -0,0 +1,58 @@ + + + + + + + + + + + Showing #{movieFacadeREST.countREST()} movies in #{theaterFacadeREST.countREST()} theaters! + + + + + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/points/points.xhtml b/solution/movieplex7-ear/web/src/main/webapp/points/points.xhtml new file mode 100644 index 0000000..04f5325 --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/points/points.xhtml @@ -0,0 +1,69 @@ + + + + + + + + + + +

Points

+ + + Queue size:

+ + + + + + + + + + + + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/resources/css/cssLayout.css b/solution/movieplex7-ear/web/src/main/webapp/resources/css/cssLayout.css new file mode 100644 index 0000000..8ee7ceb --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/resources/css/cssLayout.css @@ -0,0 +1,61 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + +#left { + float: left; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #ece3a5; + padding: 5px; + width: 150px; +} + +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} + +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/resources/css/default.css b/solution/movieplex7-ear/web/src/main/webapp/resources/css/default.css new file mode 100644 index 0000000..6cbc3d1 --- /dev/null +++ b/solution/movieplex7-ear/web/src/main/webapp/resources/css/default.css @@ -0,0 +1,29 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 16px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #045491; + font-weight : bold; + text-decoration : underline; +} From 671f58cb69494f715b826de226fa1705ff079a78 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sun, 22 Mar 2015 20:25:34 -0700 Subject: [PATCH 02/25] fixing name, removing redundant dependencies and fragments --- solution/movieplex7-ear/web/pom.xml | 42 ++++------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/solution/movieplex7-ear/web/pom.xml b/solution/movieplex7-ear/web/pom.xml index 47faeaa..c20edfa 100644 --- a/solution/movieplex7-ear/web/pom.xml +++ b/solution/movieplex7-ear/web/pom.xml @@ -2,13 +2,13 @@ 4.0.0 - movieplex7 - org.javaee7 - 1.0-SNAPSHOT - + movieplex7 + org.javaee7 + 1.0-SNAPSHOT + org.javaee7.movieplex7 - web + movieplex7 1.0-SNAPSHOT war @@ -18,15 +18,6 @@ ${project.build.directory}/endorsed UTF-8 - - - - javax - javaee-web-api - 7.0 - provided - - @@ -37,9 +28,6 @@ 1.7 1.7 - - ${endorsed.dir} - @@ -54,26 +42,6 @@ org.apache.maven.plugins maven-dependency-plugin 2.6 - - - validate - - copy - - - ${endorsed.dir} - true - - - javax - javaee-endorsed-api - 7.0 - jar - - - - - From 3cac70c0d3111e8fbce0addb676d3eb50082fe18 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sun, 22 Mar 2015 20:26:04 -0700 Subject: [PATCH 03/25] adding glassfish-maven-plugin --- solution/movieplex7-ear/ear/pom.xml | 48 +++++++++++++++++++++++++++-- solution/movieplex7-ear/pom.xml | 40 +++++++++++++++++++++++- 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/solution/movieplex7-ear/ear/pom.xml b/solution/movieplex7-ear/ear/pom.xml index 0568796..633fc74 100644 --- a/solution/movieplex7-ear/ear/pom.xml +++ b/solution/movieplex7-ear/ear/pom.xml @@ -2,16 +2,36 @@ 4.0.0 - movieplex7 org.javaee7 + movieplex7 1.0-SNAPSHOT org.javaee7.movieplex7 - ear + 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 web @@ -126,6 +146,30 @@ false + + org.glassfish.maven.plugin + maven-glassfish-plugin + 2.1 + + false + admin + ${glassfish.password.file} + + domain1 + 8080 + 4848 + + + + ${project.artifactId} + target/${project.build.finalName}.ear + + + true + false + true + + \ No newline at end of file diff --git a/solution/movieplex7-ear/pom.xml b/solution/movieplex7-ear/pom.xml index 6db059f..743fa3a 100644 --- a/solution/movieplex7-ear/pom.xml +++ b/solution/movieplex7-ear/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.javaee7 - movieplex7 + movieplex7-parent 1.0-SNAPSHOT pom @@ -21,6 +21,20 @@ 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 + + @@ -59,6 +73,30 @@ true + + 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 + + From 3104984b574eed42b40e89325e2cd2453b4cbd17 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sun, 22 Mar 2015 20:59:10 -0700 Subject: [PATCH 04/25] fixing pom parent name, adding pluginManagement and simplifying child poms --- solution/movieplex7-ear/batch/pom.xml | 6 +- solution/movieplex7-ear/booking/pom.xml | 8 +- solution/movieplex7-ear/chat/pom.xml | 5 +- solution/movieplex7-ear/client/pom.xml | 4 +- solution/movieplex7-ear/ear/pom.xml | 28 +--- solution/movieplex7-ear/entities/pom.xml | 3 +- solution/movieplex7-ear/json/pom.xml | 6 +- solution/movieplex7-ear/points/pom.xml | 5 +- solution/movieplex7-ear/pom.xml | 126 +++++++++++++----- solution/movieplex7-ear/rest/pom.xml | 6 +- solution/movieplex7-ear/web/pom.xml | 23 +--- .../web/src/main/webapp/WEB-INF/jboss-web.xml | 4 - 12 files changed, 104 insertions(+), 120 deletions(-) delete mode 100644 solution/movieplex7-ear/web/src/main/webapp/WEB-INF/jboss-web.xml diff --git a/solution/movieplex7-ear/batch/pom.xml b/solution/movieplex7-ear/batch/pom.xml index 07f32be..3714353 100644 --- a/solution/movieplex7-ear/batch/pom.xml +++ b/solution/movieplex7-ear/batch/pom.xml @@ -3,21 +3,17 @@ 4.0.0 org.javaee7 - movieplex7 + movieplex7-parent 1.0-SNAPSHOT org.javaee7.movieplex7 batch jar - - UTF-8 - org.javaee7.movieplex7 entities - 1.0-SNAPSHOT \ No newline at end of file diff --git a/solution/movieplex7-ear/booking/pom.xml b/solution/movieplex7-ear/booking/pom.xml index 008cf7d..996ead1 100644 --- a/solution/movieplex7-ear/booking/pom.xml +++ b/solution/movieplex7-ear/booking/pom.xml @@ -3,23 +3,21 @@ 4.0.0 org.javaee7 - movieplex7 + movieplex7-parent 1.0-SNAPSHOT - org.javaee7.movieplex7 - booking + org.javaee7.movieplex7 + booking jar org.javaee7.movieplex7 entities - 1.0-SNAPSHOT org.javaee7.movieplex7 json - 1.0-SNAPSHOT \ No newline at end of file diff --git a/solution/movieplex7-ear/chat/pom.xml b/solution/movieplex7-ear/chat/pom.xml index 32f9501..804f3d3 100644 --- a/solution/movieplex7-ear/chat/pom.xml +++ b/solution/movieplex7-ear/chat/pom.xml @@ -3,13 +3,10 @@ 4.0.0 org.javaee7 - movieplex7 + movieplex7-parent 1.0-SNAPSHOT org.javaee7.movieplex7 chat jar - - UTF-8 - \ No newline at end of file diff --git a/solution/movieplex7-ear/client/pom.xml b/solution/movieplex7-ear/client/pom.xml index 27e31a0..304dbd0 100644 --- a/solution/movieplex7-ear/client/pom.xml +++ b/solution/movieplex7-ear/client/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.javaee7 - movieplex7 + movieplex7-parent 1.0-SNAPSHOT org.javaee7.movieplex7 @@ -13,12 +13,10 @@ org.javaee7.movieplex7 entities - 1.0-SNAPSHOT org.javaee7.movieplex7 json - 1.0-SNAPSHOT \ No newline at end of file diff --git a/solution/movieplex7-ear/ear/pom.xml b/solution/movieplex7-ear/ear/pom.xml index 633fc74..1fb5dc2 100644 --- a/solution/movieplex7-ear/ear/pom.xml +++ b/solution/movieplex7-ear/ear/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.javaee7 - movieplex7 + movieplex7-parent 1.0-SNAPSHOT org.javaee7.movieplex7 @@ -85,11 +85,6 @@ org.apache.maven.plugins maven-compiler-plugin - 2.3.2 - - 1.7 - 1.7 - org.apache.maven.plugins @@ -141,7 +136,6 @@ org.wildfly.plugins wildfly-maven-plugin - 1.0.2.Final false @@ -149,26 +143,6 @@ org.glassfish.maven.plugin maven-glassfish-plugin - 2.1 - - false - admin - ${glassfish.password.file} - - domain1 - 8080 - 4848 - - - - ${project.artifactId} - target/${project.build.finalName}.ear - - - true - false - true - diff --git a/solution/movieplex7-ear/entities/pom.xml b/solution/movieplex7-ear/entities/pom.xml index c4b77b1..af02596 100644 --- a/solution/movieplex7-ear/entities/pom.xml +++ b/solution/movieplex7-ear/entities/pom.xml @@ -3,11 +3,10 @@ 4.0.0 org.javaee7 - movieplex7 + movieplex7-parent 1.0-SNAPSHOT org.javaee7.movieplex7 entities jar - 1.0-SNAPSHOT \ No newline at end of file diff --git a/solution/movieplex7-ear/json/pom.xml b/solution/movieplex7-ear/json/pom.xml index 2e744b1..e324e88 100644 --- a/solution/movieplex7-ear/json/pom.xml +++ b/solution/movieplex7-ear/json/pom.xml @@ -3,21 +3,17 @@ 4.0.0 org.javaee7 - movieplex7 + movieplex7-parent 1.0-SNAPSHOT org.javaee7.movieplex7 json jar - - UTF-8 - org.javaee7.movieplex7 entities - 1.0-SNAPSHOT \ No newline at end of file diff --git a/solution/movieplex7-ear/points/pom.xml b/solution/movieplex7-ear/points/pom.xml index b40f06e..5b62978 100644 --- a/solution/movieplex7-ear/points/pom.xml +++ b/solution/movieplex7-ear/points/pom.xml @@ -3,13 +3,10 @@ 4.0.0 org.javaee7 - movieplex7 + movieplex7-parent 1.0-SNAPSHOT org.javaee7.movieplex7 points jar - - UTF-8 - \ No newline at end of file diff --git a/solution/movieplex7-ear/pom.xml b/solution/movieplex7-ear/pom.xml index 743fa3a..fd2ba22 100644 --- a/solution/movieplex7-ear/pom.xml +++ b/solution/movieplex7-ear/pom.xml @@ -44,9 +44,55 @@ 7.0 provided + + org.javaee7.movieplex7 + web + 1.0-SNAPSHOT + war + + + org.javaee7.movieplex7 + batch + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + booking + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + chat + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + client + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + entities + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + json + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + points + 1.0-SNAPSHOT + + + org.javaee7.movieplex7 + rest + 1.0-SNAPSHOT + - + javax @@ -55,47 +101,59 @@ + + + + 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.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 - 2.3.2 - - 1.7 - 1.7 - org.wildfly.plugins wildfly-maven-plugin - 1.0.2.Final - - true - - - - 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 - diff --git a/solution/movieplex7-ear/rest/pom.xml b/solution/movieplex7-ear/rest/pom.xml index 11ef707..ad30b5f 100644 --- a/solution/movieplex7-ear/rest/pom.xml +++ b/solution/movieplex7-ear/rest/pom.xml @@ -3,21 +3,17 @@ 4.0.0 org.javaee7 - movieplex7 + movieplex7-parent 1.0-SNAPSHOT org.javaee7.movieplex7 rest jar - - UTF-8 - org.javaee7.movieplex7 entities - 1.0-SNAPSHOT \ No newline at end of file diff --git a/solution/movieplex7-ear/web/pom.xml b/solution/movieplex7-ear/web/pom.xml index c20edfa..9014980 100644 --- a/solution/movieplex7-ear/web/pom.xml +++ b/solution/movieplex7-ear/web/pom.xml @@ -2,8 +2,8 @@ 4.0.0 - movieplex7 org.javaee7 + movieplex7-parent 1.0-SNAPSHOT @@ -12,36 +12,15 @@ 1.0-SNAPSHOT war - movieplex7 - - - ${project.build.directory}/endorsed - UTF-8 - - org.apache.maven.plugins maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - org.apache.maven.plugins maven-war-plugin - 2.3 - - false - - - - org.apache.maven.plugins - maven-dependency-plugin - 2.6 diff --git a/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/jboss-web.xml b/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/jboss-web.xml deleted file mode 100644 index d1352c4..0000000 --- a/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/jboss-web.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - /movieplex7 - From 0ec6a77c20108c1b505e5df5dbffd234599d71ab Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sun, 22 Mar 2015 22:25:41 -0700 Subject: [PATCH 05/25] setting the project type appropriately --- solution/movieplex7-ear/batch/pom.xml | 11 +++++++- solution/movieplex7-ear/booking/pom.xml | 12 ++++++++- solution/movieplex7-ear/chat/pom.xml | 11 +++++++- solution/movieplex7-ear/client/pom.xml | 12 ++++++++- solution/movieplex7-ear/ear/pom.xml | 35 +++++++++++-------------- solution/movieplex7-ear/json/pom.xml | 9 +++++++ solution/movieplex7-ear/points/pom.xml | 11 +++++++- solution/movieplex7-ear/pom.xml | 24 +++++++++++++---- solution/movieplex7-ear/rest/pom.xml | 12 ++++++++- solution/movieplex7-ear/web/pom.xml | 4 --- 10 files changed, 106 insertions(+), 35 deletions(-) diff --git a/solution/movieplex7-ear/batch/pom.xml b/solution/movieplex7-ear/batch/pom.xml index 3714353..f8418f8 100644 --- a/solution/movieplex7-ear/batch/pom.xml +++ b/solution/movieplex7-ear/batch/pom.xml @@ -8,7 +8,7 @@ org.javaee7.movieplex7 batch - jar + war @@ -16,4 +16,13 @@ entities + + + + + org.apache.maven.plugins + maven-war-plugin + + + \ No newline at end of file diff --git a/solution/movieplex7-ear/booking/pom.xml b/solution/movieplex7-ear/booking/pom.xml index 996ead1..1db7b90 100644 --- a/solution/movieplex7-ear/booking/pom.xml +++ b/solution/movieplex7-ear/booking/pom.xml @@ -8,7 +8,7 @@ org.javaee7.movieplex7 booking - jar + @@ -18,6 +18,16 @@ org.javaee7.movieplex7 json + + + \ No newline at end of file diff --git a/solution/movieplex7-ear/chat/pom.xml b/solution/movieplex7-ear/chat/pom.xml index 804f3d3..6c81007 100644 --- a/solution/movieplex7-ear/chat/pom.xml +++ b/solution/movieplex7-ear/chat/pom.xml @@ -8,5 +8,14 @@ org.javaee7.movieplex7 chat - jar + war + + + + + org.apache.maven.plugins + maven-war-plugin + + + \ No newline at end of file diff --git a/solution/movieplex7-ear/client/pom.xml b/solution/movieplex7-ear/client/pom.xml index 304dbd0..a24e772 100644 --- a/solution/movieplex7-ear/client/pom.xml +++ b/solution/movieplex7-ear/client/pom.xml @@ -8,7 +8,8 @@ org.javaee7.movieplex7 client - jar + war + org.javaee7.movieplex7 @@ -19,4 +20,13 @@ json + + + + + org.apache.maven.plugins + maven-war-plugin + + + \ No newline at end of file diff --git a/solution/movieplex7-ear/ear/pom.xml b/solution/movieplex7-ear/ear/pom.xml index 1fb5dc2..483db27 100644 --- a/solution/movieplex7-ear/ear/pom.xml +++ b/solution/movieplex7-ear/ear/pom.xml @@ -35,48 +35,44 @@ org.javaee7.movieplex7 web - 1.0-SNAPSHOT war org.javaee7.movieplex7 batch - 1.0-SNAPSHOT + war org.javaee7.movieplex7 booking - 1.0-SNAPSHOT org.javaee7.movieplex7 chat - 1.0-SNAPSHOT + war org.javaee7.movieplex7 client - 1.0-SNAPSHOT + war org.javaee7.movieplex7 entities - 1.0-SNAPSHOT org.javaee7.movieplex7 json - 1.0-SNAPSHOT org.javaee7.movieplex7 points - 1.0-SNAPSHOT + war org.javaee7.movieplex7 rest - 1.0-SNAPSHOT + war @@ -91,7 +87,6 @@ maven-ear-plugin 2.10 - org.javaee7.movieplex7 @@ -102,34 +97,34 @@ entities lib - + org.javaee7.movieplex7 batch - + org.javaee7.movieplex7 booking - + org.javaee7.movieplex7 chat - - + + org.javaee7.movieplex7 client - + org.javaee7.movieplex7 json - + org.javaee7.movieplex7 points - - + + org.javaee7.movieplex7 rest - + diff --git a/solution/movieplex7-ear/json/pom.xml b/solution/movieplex7-ear/json/pom.xml index e324e88..851d029 100644 --- a/solution/movieplex7-ear/json/pom.xml +++ b/solution/movieplex7-ear/json/pom.xml @@ -16,4 +16,13 @@ entities + + \ No newline at end of file diff --git a/solution/movieplex7-ear/points/pom.xml b/solution/movieplex7-ear/points/pom.xml index 5b62978..cc566ce 100644 --- a/solution/movieplex7-ear/points/pom.xml +++ b/solution/movieplex7-ear/points/pom.xml @@ -8,5 +8,14 @@ org.javaee7.movieplex7 points - jar + war + + + + + org.apache.maven.plugins + maven-war-plugin + + + \ No newline at end of file diff --git a/solution/movieplex7-ear/pom.xml b/solution/movieplex7-ear/pom.xml index fd2ba22..130fdf6 100644 --- a/solution/movieplex7-ear/pom.xml +++ b/solution/movieplex7-ear/pom.xml @@ -52,28 +52,32 @@ org.javaee7.movieplex7 - batch + entities 1.0-SNAPSHOT org.javaee7.movieplex7 - booking + batch 1.0-SNAPSHOT + war org.javaee7.movieplex7 - chat + booking 1.0-SNAPSHOT + org.javaee7.movieplex7 - client + chat 1.0-SNAPSHOT + war org.javaee7.movieplex7 - entities + client 1.0-SNAPSHOT + war org.javaee7.movieplex7 @@ -84,11 +88,13 @@ org.javaee7.movieplex7 points 1.0-SNAPSHOT + war org.javaee7.movieplex7 rest 1.0-SNAPSHOT + war @@ -120,6 +126,14 @@ true + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + false + + org.glassfish.maven.plugin maven-glassfish-plugin diff --git a/solution/movieplex7-ear/rest/pom.xml b/solution/movieplex7-ear/rest/pom.xml index ad30b5f..7a19708 100644 --- a/solution/movieplex7-ear/rest/pom.xml +++ b/solution/movieplex7-ear/rest/pom.xml @@ -8,7 +8,7 @@ org.javaee7.movieplex7 rest - jar + war @@ -16,4 +16,14 @@ entities + + + + + org.apache.maven.plugins + maven-war-plugin + + + + \ No newline at end of file diff --git a/solution/movieplex7-ear/web/pom.xml b/solution/movieplex7-ear/web/pom.xml index 9014980..718e858 100644 --- a/solution/movieplex7-ear/web/pom.xml +++ b/solution/movieplex7-ear/web/pom.xml @@ -14,10 +14,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - org.apache.maven.plugins maven-war-plugin From 8132dc157907cb1e03fe41e2859ee0c627337ce4 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sun, 22 Mar 2015 22:26:02 -0700 Subject: [PATCH 06/25] fixing the url for rest web module --- .../java/org/javaee7/movieplex7/client/MovieClientBean.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 index 3a154e4..50309f0 100644 --- 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 @@ -76,9 +76,10 @@ public void init() { httpServletRequest.getLocalName() + ":" + httpServletRequest.getLocalPort() + - "/" + - httpServletRequest.getContextPath() + + "/rest" + +// httpServletRequest.getContextPath() + "/webresources/movie/"); + System.out.println("MovieClientBean.PostConstruct"); } @PreDestroy From 84beb24261df388ee9ce93376fb315a032733671 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Fri, 27 Mar 2015 18:52:23 +0100 Subject: [PATCH 07/25] moving contracts to a different directory, working on fixing flows --- .../src/main/webapp/batch/sales.xhtml | 0 .../booking/booking-flow.NavData | 6 ++ solution/movieplex7-ear/booking/pom.xml | 11 ++-- .../src/main/webapp/booking/booking-flow.xml | 0 .../src/main/webapp/booking/booking.xhtml | 26 +++++---- .../src/main/webapp/booking/confirm.xhtml | 55 ++++++++++--------- .../src/main/webapp/booking/print.xhtml | 27 +++++---- .../src/main/webapp/booking/showtimes.xhtml | 32 +++++++++++ .../src/main/webapp/chat/chatroom.xhtml | 0 .../src/main/webapp/chat/websocket.js | 0 .../src/main/webapp/client/addmovie.xhtml | 0 .../src/main/webapp/client/movie.xhtml | 0 .../src/main/webapp/client/movies.xhtml | 0 solution/movieplex7-ear/contracts/pom.xml | 12 ++++ .../contracts/main}/css/cssLayout.css | 0 .../META-INF/contracts/main}/css/default.css | 0 .../contracts/main/javax.faces.contract.xml | 0 .../META-INF/contracts/main}/template.xhtml | 6 +- solution/movieplex7-ear/ear/pom.xml | 14 ++++- .../src/main/webapp/points/points.xhtml | 0 solution/movieplex7-ear/pom.xml | 16 +++++- .../movieplex7-ear/web/faces-config.NavData | 6 ++ solution/movieplex7-ear/web/pom.xml | 5 +- .../src/main/webapp/booking/showtimes.xhtml | 30 ---------- .../web/src/main/webapp/index.xhtml | 15 +++-- 25 files changed, 163 insertions(+), 98 deletions(-) rename solution/movieplex7-ear/{web => batch}/src/main/webapp/batch/sales.xhtml (100%) create mode 100644 solution/movieplex7-ear/booking/booking-flow.NavData rename solution/movieplex7-ear/{web => booking}/src/main/webapp/booking/booking-flow.xml (100%) rename solution/movieplex7-ear/{web => booking}/src/main/webapp/booking/booking.xhtml (77%) rename solution/movieplex7-ear/{web => booking}/src/main/webapp/booking/confirm.xhtml (62%) rename solution/movieplex7-ear/{web => booking}/src/main/webapp/booking/print.xhtml (77%) create mode 100644 solution/movieplex7-ear/booking/src/main/webapp/booking/showtimes.xhtml rename solution/movieplex7-ear/{web => chat}/src/main/webapp/chat/chatroom.xhtml (100%) rename solution/movieplex7-ear/{web => chat}/src/main/webapp/chat/websocket.js (100%) rename solution/movieplex7-ear/{web => client}/src/main/webapp/client/addmovie.xhtml (100%) rename solution/movieplex7-ear/{web => client}/src/main/webapp/client/movie.xhtml (100%) rename solution/movieplex7-ear/{web => client}/src/main/webapp/client/movies.xhtml (100%) create mode 100644 solution/movieplex7-ear/contracts/pom.xml rename solution/movieplex7-ear/{web/src/main/webapp/resources => contracts/src/main/resources/META-INF/contracts/main}/css/cssLayout.css (100%) rename solution/movieplex7-ear/{web/src/main/webapp/resources => contracts/src/main/resources/META-INF/contracts/main}/css/default.css (100%) create mode 100644 solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/javax.faces.contract.xml rename solution/movieplex7-ear/{web/src/main/webapp/WEB-INF => contracts/src/main/resources/META-INF/contracts/main}/template.xhtml (90%) rename solution/movieplex7-ear/{web => points}/src/main/webapp/points/points.xhtml (100%) create mode 100644 solution/movieplex7-ear/web/faces-config.NavData delete mode 100644 solution/movieplex7-ear/web/src/main/webapp/booking/showtimes.xhtml diff --git a/solution/movieplex7-ear/web/src/main/webapp/batch/sales.xhtml b/solution/movieplex7-ear/batch/src/main/webapp/batch/sales.xhtml similarity index 100% rename from solution/movieplex7-ear/web/src/main/webapp/batch/sales.xhtml rename to solution/movieplex7-ear/batch/src/main/webapp/batch/sales.xhtml 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 index 1db7b90..bf6c9b0 100644 --- a/solution/movieplex7-ear/booking/pom.xml +++ b/solution/movieplex7-ear/booking/pom.xml @@ -8,7 +8,7 @@ org.javaee7.movieplex7 booking - + war @@ -18,16 +18,19 @@ org.javaee7.movieplex7 json - + + + org.javaee7.movieplex7 + contracts - + \ No newline at end of file diff --git a/solution/movieplex7-ear/web/src/main/webapp/booking/booking-flow.xml b/solution/movieplex7-ear/booking/src/main/webapp/booking/booking-flow.xml similarity index 100% rename from solution/movieplex7-ear/web/src/main/webapp/booking/booking-flow.xml rename to solution/movieplex7-ear/booking/src/main/webapp/booking/booking-flow.xml diff --git a/solution/movieplex7-ear/web/src/main/webapp/booking/booking.xhtml b/solution/movieplex7-ear/booking/src/main/webapp/booking/booking.xhtml similarity index 77% rename from solution/movieplex7-ear/web/src/main/webapp/booking/booking.xhtml rename to solution/movieplex7-ear/booking/src/main/webapp/booking/booking.xhtml index 00dfd6a..c267811 100644 --- a/solution/movieplex7-ear/web/src/main/webapp/booking/booking.xhtml +++ b/solution/movieplex7-ear/booking/src/main/webapp/booking/booking.xhtml @@ -49,23 +49,25 @@ - + + - -

Pick a movie

- + +

Pick a movie

+ - - - - - + + + - + -
+
-
+ + + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/booking/confirm.xhtml b/solution/movieplex7-ear/booking/src/main/webapp/booking/confirm.xhtml similarity index 62% rename from solution/movieplex7-ear/web/src/main/webapp/booking/confirm.xhtml rename to solution/movieplex7-ear/booking/src/main/webapp/booking/confirm.xhtml index 908ae5a..d89b632 100644 --- a/solution/movieplex7-ear/web/src/main/webapp/booking/confirm.xhtml +++ b/solution/movieplex7-ear/booking/src/main/webapp/booking/confirm.xhtml @@ -45,38 +45,41 @@ + xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" + xmlns:f="http://xmlns.jcp.org/jsf/core"> - + + - - - -

No theater found, choose a different time

- - Movie name: #{booking.movieName}

- Starts at: #{booking.startTime}

+ + + +

No theater found, choose a different time

+ + Movie name: #{booking.movieName}

+ Starts at: #{booking.startTime}

- - - -

Confirm ?

- - - Movie name: #{booking.movieName}

- Starts at: #{booking.startTime}

- Theater: #{booking.theater}

-

-

-
- -
- -
+ + + +

Confirm ?

+ + + Movie name: #{booking.movieName}

+ Starts at: #{booking.startTime}

+ Theater: #{booking.theater}

+

+

+
+
+ -
+ + +
+ diff --git a/solution/movieplex7-ear/web/src/main/webapp/booking/print.xhtml b/solution/movieplex7-ear/booking/src/main/webapp/booking/print.xhtml similarity index 77% rename from solution/movieplex7-ear/web/src/main/webapp/booking/print.xhtml rename to solution/movieplex7-ear/booking/src/main/webapp/booking/print.xhtml index fcaa28c..7281708 100644 --- a/solution/movieplex7-ear/web/src/main/webapp/booking/print.xhtml +++ b/solution/movieplex7-ear/booking/src/main/webapp/booking/print.xhtml @@ -44,25 +44,28 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:f="http://xmlns.jcp.org/jsf/core"> - + + - -

Reservation Confirmed

+ +

Reservation Confirmed

- - Movie name: #{booking.movieName}

- Starts at: #{booking.startTime}

- Theater: #{booking.theater}

+ + Movie name: #{booking.movieName}

+ Starts at: #{booking.startTime}

+ Theater: #{booking.theater}

-

-
-
+

+ +
-
+
+ diff --git a/solution/movieplex7-ear/booking/src/main/webapp/booking/showtimes.xhtml b/solution/movieplex7-ear/booking/src/main/webapp/booking/showtimes.xhtml new file mode 100644 index 0000000..26fabba --- /dev/null +++ b/solution/movieplex7-ear/booking/src/main/webapp/booking/showtimes.xhtml @@ -0,0 +1,32 @@ + + + + + + + + + + +

Show Timings for #{booking.movieName}

+ + + + + + + + + + +
+ +
+
+ + + diff --git a/solution/movieplex7-ear/web/src/main/webapp/chat/chatroom.xhtml b/solution/movieplex7-ear/chat/src/main/webapp/chat/chatroom.xhtml similarity index 100% rename from solution/movieplex7-ear/web/src/main/webapp/chat/chatroom.xhtml rename to solution/movieplex7-ear/chat/src/main/webapp/chat/chatroom.xhtml diff --git a/solution/movieplex7-ear/web/src/main/webapp/chat/websocket.js b/solution/movieplex7-ear/chat/src/main/webapp/chat/websocket.js similarity index 100% rename from solution/movieplex7-ear/web/src/main/webapp/chat/websocket.js rename to solution/movieplex7-ear/chat/src/main/webapp/chat/websocket.js diff --git a/solution/movieplex7-ear/web/src/main/webapp/client/addmovie.xhtml b/solution/movieplex7-ear/client/src/main/webapp/client/addmovie.xhtml similarity index 100% rename from solution/movieplex7-ear/web/src/main/webapp/client/addmovie.xhtml rename to solution/movieplex7-ear/client/src/main/webapp/client/addmovie.xhtml diff --git a/solution/movieplex7-ear/web/src/main/webapp/client/movie.xhtml b/solution/movieplex7-ear/client/src/main/webapp/client/movie.xhtml similarity index 100% rename from solution/movieplex7-ear/web/src/main/webapp/client/movie.xhtml rename to solution/movieplex7-ear/client/src/main/webapp/client/movie.xhtml diff --git a/solution/movieplex7-ear/web/src/main/webapp/client/movies.xhtml b/solution/movieplex7-ear/client/src/main/webapp/client/movies.xhtml similarity index 100% rename from solution/movieplex7-ear/web/src/main/webapp/client/movies.xhtml rename to solution/movieplex7-ear/client/src/main/webapp/client/movies.xhtml diff --git a/solution/movieplex7-ear/contracts/pom.xml b/solution/movieplex7-ear/contracts/pom.xml new file mode 100644 index 0000000..60415e3 --- /dev/null +++ b/solution/movieplex7-ear/contracts/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.javaee7 + movieplex7-parent + 1.0-SNAPSHOT + + org.javaee7.movieplex7 + contracts + jar + \ No newline at end of file diff --git a/solution/movieplex7-ear/web/src/main/webapp/resources/css/cssLayout.css b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/css/cssLayout.css similarity index 100% rename from solution/movieplex7-ear/web/src/main/webapp/resources/css/cssLayout.css rename to solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/css/cssLayout.css diff --git a/solution/movieplex7-ear/web/src/main/webapp/resources/css/default.css b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/css/default.css similarity index 100% rename from solution/movieplex7-ear/web/src/main/webapp/resources/css/default.css rename to solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/css/default.css diff --git a/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/javax.faces.contract.xml b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/javax.faces.contract.xml new file mode 100644 index 0000000..e69de29 diff --git a/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/template.xhtml b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml similarity index 90% rename from solution/movieplex7-ear/web/src/main/webapp/WEB-INF/template.xhtml rename to solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml index dc0fc21..af9e496 100644 --- a/solution/movieplex7-ear/web/src/main/webapp/WEB-INF/template.xhtml +++ b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml @@ -48,8 +48,8 @@ - - + + Movieplex 7 @@ -76,7 +76,7 @@ Book a movie -

Chat Room +

Chat Room

Movies

Sales

Points diff --git a/solution/movieplex7-ear/ear/pom.xml b/solution/movieplex7-ear/ear/pom.xml index 483db27..9fcb160 100644 --- a/solution/movieplex7-ear/ear/pom.xml +++ b/solution/movieplex7-ear/ear/pom.xml @@ -45,6 +45,7 @@ org.javaee7.movieplex7 booking + war org.javaee7.movieplex7 @@ -74,6 +75,10 @@ rest war + + org.javaee7.movieplex7 + contracts + @@ -101,10 +106,10 @@ org.javaee7.movieplex7 batch - + org.javaee7.movieplex7 booking - + org.javaee7.movieplex7 chat @@ -116,6 +121,11 @@ org.javaee7.movieplex7 json + lib + + + org.javaee7.movieplex7 + contracts org.javaee7.movieplex7 diff --git a/solution/movieplex7-ear/web/src/main/webapp/points/points.xhtml b/solution/movieplex7-ear/points/src/main/webapp/points/points.xhtml similarity index 100% rename from solution/movieplex7-ear/web/src/main/webapp/points/points.xhtml rename to solution/movieplex7-ear/points/src/main/webapp/points/points.xhtml diff --git a/solution/movieplex7-ear/pom.xml b/solution/movieplex7-ear/pom.xml index 130fdf6..acd81b5 100644 --- a/solution/movieplex7-ear/pom.xml +++ b/solution/movieplex7-ear/pom.xml @@ -18,6 +18,7 @@ client web ear + contracts Java EE 7 Hands-on Lab Solution - MSA @@ -54,30 +55,35 @@ 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 @@ -89,12 +95,20 @@ points 1.0-SNAPSHOT war + provided org.javaee7.movieplex7 rest 1.0-SNAPSHOT war + provided + + + org.javaee7.movieplex7 + contracts + 1.0-SNAPSHOT + provided diff --git a/solution/movieplex7-ear/web/faces-config.NavData b/solution/movieplex7-ear/web/faces-config.NavData new file mode 100644 index 0000000..298bfc5 --- /dev/null +++ b/solution/movieplex7-ear/web/faces-config.NavData @@ -0,0 +1,6 @@ + + + + + + diff --git a/solution/movieplex7-ear/web/pom.xml b/solution/movieplex7-ear/web/pom.xml index 718e858..76c2707 100644 --- a/solution/movieplex7-ear/web/pom.xml +++ b/solution/movieplex7-ear/web/pom.xml @@ -8,11 +8,12 @@ org.javaee7.movieplex7 - movieplex7 + movieplex7-web 1.0-SNAPSHOT war + movieplex7 org.apache.maven.plugins @@ -20,5 +21,5 @@ - + diff --git a/solution/movieplex7-ear/web/src/main/webapp/booking/showtimes.xhtml b/solution/movieplex7-ear/web/src/main/webapp/booking/showtimes.xhtml deleted file mode 100644 index 4373d54..0000000 --- a/solution/movieplex7-ear/web/src/main/webapp/booking/showtimes.xhtml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - -

Show Timings for #{booking.movieName}

- - - - - - - - - - - - - - - - diff --git a/solution/movieplex7-ear/web/src/main/webapp/index.xhtml b/solution/movieplex7-ear/web/src/main/webapp/index.xhtml index e5362b3..fa7e4f6 100644 --- a/solution/movieplex7-ear/web/src/main/webapp/index.xhtml +++ b/solution/movieplex7-ear/web/src/main/webapp/index.xhtml @@ -42,17 +42,20 @@ --> + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" + xmlns:f="http://xmlns.jcp.org/jsf/core"> - + + - - Showing #{movieFacadeREST.countREST()} movies in #{theaterFacadeREST.countREST()} theaters! - + + Showing #{movieFacadeREST.countREST()} movies in #{theaterFacadeREST.countREST()} theaters! + - + + From 3b05a64784634e25a6360852d65acb5f9b335990 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Fri, 27 Mar 2015 21:30:30 +0100 Subject: [PATCH 08/25] fixed artifact names --- solution/movieplex7-ear/ear/pom.xml | 4 ++-- solution/movieplex7-ear/pom.xml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/solution/movieplex7-ear/ear/pom.xml b/solution/movieplex7-ear/ear/pom.xml index 9fcb160..d9b4625 100644 --- a/solution/movieplex7-ear/ear/pom.xml +++ b/solution/movieplex7-ear/ear/pom.xml @@ -34,7 +34,7 @@ org.javaee7.movieplex7 - web + movieplex7-web war @@ -95,7 +95,7 @@ org.javaee7.movieplex7 - web + movieplex7-web org.javaee7.movieplex7 diff --git a/solution/movieplex7-ear/pom.xml b/solution/movieplex7-ear/pom.xml index acd81b5..20fdd23 100644 --- a/solution/movieplex7-ear/pom.xml +++ b/solution/movieplex7-ear/pom.xml @@ -47,7 +47,7 @@ org.javaee7.movieplex7 - web + movieplex7-web 1.0-SNAPSHOT war @@ -89,6 +89,7 @@ org.javaee7.movieplex7 json 1.0-SNAPSHOT + provided org.javaee7.movieplex7 From ab3a6c04cfe180217852cfe2026b2e8b08f844bc Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Fri, 27 Mar 2015 21:38:32 +0100 Subject: [PATCH 09/25] fixing contracts --- .../chat/src/main/webapp/chat/chatroom.xhtml | 61 ++++++++++--------- .../src/main/webapp/client/addmovie.xhtml | 50 ++++++++------- .../client/src/main/webapp/client/movie.xhtml | 51 ++++++++-------- .../src/main/webapp/client/movies.xhtml | 33 +++++----- .../src/main/webapp/points/points.xhtml | 31 +++++----- 5 files changed, 120 insertions(+), 106 deletions(-) diff --git a/solution/movieplex7-ear/chat/src/main/webapp/chat/chatroom.xhtml b/solution/movieplex7-ear/chat/src/main/webapp/chat/chatroom.xhtml index 99e70df..56f9ff0 100644 --- a/solution/movieplex7-ear/chat/src/main/webapp/chat/chatroom.xhtml +++ b/solution/movieplex7-ear/chat/src/main/webapp/chat/chatroom.xhtml @@ -42,43 +42,46 @@ --> + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" + xmlns:f="http://xmlns.jcp.org/jsf/core"> - + + - -
+ + - - - - - - - - -
- Chat Log
- -
- Users
- -
- - -

- -

+ + + + + + + + +
+ Chat Log
+ +
+ Users
+ +
+ + +

+ +

- -
- + +
+ -
+
-
+
+ diff --git a/solution/movieplex7-ear/client/src/main/webapp/client/addmovie.xhtml b/solution/movieplex7-ear/client/src/main/webapp/client/addmovie.xhtml index b455b2e..7c75591 100644 --- a/solution/movieplex7-ear/client/src/main/webapp/client/addmovie.xhtml +++ b/solution/movieplex7-ear/client/src/main/webapp/client/addmovie.xhtml @@ -43,35 +43,39 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:f="http://xmlns.jcp.org/jsf/core"> + - + - -

Add a New Movie

- - - - - - - - - - - - - - + +

Add a New Movie

+ +
Movie Id:
Movie Name:
Movie Actors:
+ + + + + + + + + + + + -
Movie Id:
Movie Name:
Movie Actors:
- -
-
+ + +
+ - + + + diff --git a/solution/movieplex7-ear/client/src/main/webapp/client/movie.xhtml b/solution/movieplex7-ear/client/src/main/webapp/client/movie.xhtml index 1a0c3a8..ad26cfe 100644 --- a/solution/movieplex7-ear/client/src/main/webapp/client/movie.xhtml +++ b/solution/movieplex7-ear/client/src/main/webapp/client/movie.xhtml @@ -43,35 +43,38 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:f="http://xmlns.jcp.org/jsf/core"> - + + - -

Movie Details

- - - - - - - - - - - - - - - -
Movie Id:#{movieClientBean.movie.id}
Movie Name:#{movieClientBean.movie.name}
Movie Actors:#{movieClientBean.movie.actors}
- -
-
+ +

Movie Details

+ + + + + + + + + + + + + + - +
Movie Id:#{movieClientBean.movie.id}
Movie Name:#{movieClientBean.movie.name}
Movie Actors:#{movieClientBean.movie.actors}
+ +
+
+ +
+
diff --git a/solution/movieplex7-ear/client/src/main/webapp/client/movies.xhtml b/solution/movieplex7-ear/client/src/main/webapp/client/movies.xhtml index 7f812e2..0084204 100644 --- a/solution/movieplex7-ear/client/src/main/webapp/client/movies.xhtml +++ b/solution/movieplex7-ear/client/src/main/webapp/client/movies.xhtml @@ -49,25 +49,26 @@ - + + - + -

List of Movies

- - - - - - +

List of Movies

+ + + + + + - - - - -
- -
+ + + + + +
+ diff --git a/solution/movieplex7-ear/points/src/main/webapp/points/points.xhtml b/solution/movieplex7-ear/points/src/main/webapp/points/points.xhtml index 04f5325..6624f68 100644 --- a/solution/movieplex7-ear/points/src/main/webapp/points/points.xhtml +++ b/solution/movieplex7-ear/points/src/main/webapp/points/points.xhtml @@ -43,27 +43,30 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:f="http://xmlns.jcp.org/jsf/core"> - + + - -

Points

- + +

Points

+ - Queue size:

- + Queue size:

+ - - - - - - + + + + + + - + + From b74e501a93cd3909365865d36e79385cd9a53c3b Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Fri, 27 Mar 2015 21:54:33 +0100 Subject: [PATCH 10/25] explicitly adding all the resources --- solution/movieplex7-ear/rest/pom.xml | 4 ++ .../movieplex7/rest/ApplicationConfig.java | 40 +++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/solution/movieplex7-ear/rest/pom.xml b/solution/movieplex7-ear/rest/pom.xml index 7a19708..90bfa89 100644 --- a/solution/movieplex7-ear/rest/pom.xml +++ b/solution/movieplex7-ear/rest/pom.xml @@ -15,6 +15,10 @@ org.javaee7.movieplex7 entities + + org.javaee7.movieplex7 + json + 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 index bd3e38a..c9ab7a0 100644 --- 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 @@ -48,25 +48,25 @@ @javax.ws.rs.ApplicationPath("webresources") public class ApplicationConfig extends Application { -// @Override -// public Set> getClasses() { -// Set> resources = new java.util.HashSet<>(); -// addRestResourceClasses(resources); -// return resources; -// } + @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); -// } + /** + * 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); + } } From 14e7adbf8ac10d920103b000e0043d3a3bf6d32c Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Fri, 27 Mar 2015 23:49:21 +0100 Subject: [PATCH 11/25] fixing stylesheet references --- .../resources/META-INF/contracts/main/{css => }/cssLayout.css | 0 .../resources/META-INF/contracts/main/{css => }/default.css | 0 .../src/main/resources/META-INF/contracts/main/template.xhtml | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/{css => }/cssLayout.css (100%) rename solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/{css => }/default.css (100%) diff --git a/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/css/cssLayout.css b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/cssLayout.css similarity index 100% rename from solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/css/cssLayout.css rename to solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/cssLayout.css diff --git a/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/css/default.css b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/default.css similarity index 100% rename from solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/css/default.css rename to solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/default.css diff --git a/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml index af9e496..dac8d84 100644 --- a/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml +++ b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml @@ -48,8 +48,8 @@ - - + + Movieplex 7 From 5b0862338ac5404809251898a9adfbd16a867cd9 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Fri, 27 Mar 2015 23:50:06 +0100 Subject: [PATCH 12/25] bundling contracts library in lib directory --- solution/movieplex7-ear/ear/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/solution/movieplex7-ear/ear/pom.xml b/solution/movieplex7-ear/ear/pom.xml index d9b4625..ff41279 100644 --- a/solution/movieplex7-ear/ear/pom.xml +++ b/solution/movieplex7-ear/ear/pom.xml @@ -126,6 +126,7 @@ org.javaee7.movieplex7 contracts + lib org.javaee7.movieplex7 From bd24239f3b88f40e9e8e3bda31640d696fd6d932 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Fri, 27 Mar 2015 23:50:36 +0100 Subject: [PATCH 13/25] removing finalName --- solution/movieplex7-ear/web/pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/solution/movieplex7-ear/web/pom.xml b/solution/movieplex7-ear/web/pom.xml index 76c2707..3b7f3cb 100644 --- a/solution/movieplex7-ear/web/pom.xml +++ b/solution/movieplex7-ear/web/pom.xml @@ -11,9 +11,8 @@ movieplex7-web 1.0-SNAPSHOT war - + - movieplex7 org.apache.maven.plugins From af428d4f5652c7dc7eb96666636063747df3fcc0 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 00:06:03 +0100 Subject: [PATCH 14/25] adding basic readme --- solution/movieplex7-ear/readme.asciidoc | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 solution/movieplex7-ear/readme.asciidoc diff --git a/solution/movieplex7-ear/readme.asciidoc b/solution/movieplex7-ear/readme.asciidoc new file mode 100644 index 0000000..bb24f96 --- /dev/null +++ b/solution/movieplex7-ear/readme.asciidoc @@ -0,0 +1,11 @@ +# Java EE 7 EAR application + +Deploy as: + +[source, txt] +---- +mvn -o wildfly:deploy +mvn -o glassfish:deploy +---- + +Application is accessible at http://localhost:8080/movieplex7-web/faces/index.xhtml From 3b80c18087f461613eb9be0407b90866543866f7 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 00:20:08 +0100 Subject: [PATCH 15/25] adding f:view --- .../batch/src/main/webapp/batch/sales.xhtml | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/solution/movieplex7-ear/batch/src/main/webapp/batch/sales.xhtml b/solution/movieplex7-ear/batch/src/main/webapp/batch/sales.xhtml index 8cde586..d419293 100644 --- a/solution/movieplex7-ear/batch/src/main/webapp/batch/sales.xhtml +++ b/solution/movieplex7-ear/batch/src/main/webapp/batch/sales.xhtml @@ -48,32 +48,34 @@ - + + - -

Movie Sales

- - - - - - - #{s.id} - - - - - - #{s.amount} - - + +

Movie Sales

+ + + + + + + #{s.id} + + + + + + #{s.amount} + + - - - -
+ + +
+
-
+
+ From 19e08a697a3d51d1d1687749bac376ef09b364ce Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 00:20:31 +0100 Subject: [PATCH 16/25] fixing welcome file --- .../chat/src/main/webapp/WEB-INF/web.xml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 solution/movieplex7-ear/chat/src/main/webapp/WEB-INF/web.xml 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/* + + + From 3f02b772816740b30ed7aa05d5b48cd87bdba85c Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 00:20:51 +0100 Subject: [PATCH 17/25] fixing welcome file --- .../client/src/main/webapp/WEB-INF/web.xml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 solution/movieplex7-ear/client/src/main/webapp/WEB-INF/web.xml 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 + + From 3e74ccd2e8bcf642636fb1d6bd5f0d998cb1934a Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 00:21:20 +0100 Subject: [PATCH 18/25] fixing links and cleaning up code --- .../META-INF/contracts/main/template.xhtml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml index dac8d84..7669a85 100644 --- a/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml +++ b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml @@ -59,16 +59,8 @@
-

+

-
@@ -76,10 +68,10 @@ Book a movie -

Chat Room -

Movies -

Sales -

Points +

Chat Room +

Movies +

Sales +

Points

From a5ac8f3c31a6041f220f4f656df67db9ae8044d7 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 00:21:42 +0100 Subject: [PATCH 19/25] fixing welcome file --- .../points/src/main/webapp/WEB-INF/web.xml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 solution/movieplex7-ear/points/src/main/webapp/WEB-INF/web.xml 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 + + From 395226e82fa02cc0b13999f077acff8d4bba6eac Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 00:22:30 +0100 Subject: [PATCH 20/25] some reformatting --- solution/movieplex7-ear/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/solution/movieplex7-ear/pom.xml b/solution/movieplex7-ear/pom.xml index 20fdd23..9bd85b0 100644 --- a/solution/movieplex7-ear/pom.xml +++ b/solution/movieplex7-ear/pom.xml @@ -6,7 +6,7 @@ movieplex7-parent 1.0-SNAPSHOT pom - + booking batch @@ -22,13 +22,13 @@ 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 @@ -187,4 +187,4 @@ - \ No newline at end of file + From bdf8472848f60dcc56a1ddd4655dd6ebd694306e Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 00:23:32 +0100 Subject: [PATCH 21/25] adding faces-config to enable flows --- .../batch/src/main/webapp/WEB-INF/faces-config.xml | 5 +++++ .../booking/src/main/webapp/WEB-INF/faces-config.xml | 5 +++++ .../chat/src/main/webapp/WEB-INF/faces-config.xml | 5 +++++ .../client/src/main/webapp/WEB-INF/faces-config.xml | 5 +++++ .../points/src/main/webapp/WEB-INF/faces-config.xml | 5 +++++ 5 files changed, 25 insertions(+) create mode 100644 solution/movieplex7-ear/batch/src/main/webapp/WEB-INF/faces-config.xml create mode 100644 solution/movieplex7-ear/booking/src/main/webapp/WEB-INF/faces-config.xml create mode 100644 solution/movieplex7-ear/chat/src/main/webapp/WEB-INF/faces-config.xml create mode 100644 solution/movieplex7-ear/client/src/main/webapp/WEB-INF/faces-config.xml create mode 100644 solution/movieplex7-ear/points/src/main/webapp/WEB-INF/faces-config.xml 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/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/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/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/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 From 412957fc8b552f3f55393a020c3d351251fbe5a0 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 00:49:47 +0100 Subject: [PATCH 22/25] cleaned up instructions --- solution/movieplex7-ear/readme.asciidoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/solution/movieplex7-ear/readme.asciidoc b/solution/movieplex7-ear/readme.asciidoc index bb24f96..2c0fee5 100644 --- a/solution/movieplex7-ear/readme.asciidoc +++ b/solution/movieplex7-ear/readme.asciidoc @@ -4,8 +4,10 @@ Deploy as: [source, txt] ---- -mvn -o wildfly:deploy -mvn -o glassfish:deploy +mvn wildfly:deploy +mvn glassfish:deploy ---- +Subsequent redeploys are `mvn glassfish:redeploy`. + Application is accessible at http://localhost:8080/movieplex7-web/faces/index.xhtml From 0c32ba0c5addeae5c9c07de0d0644430d336df9c Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 07:48:19 +0100 Subject: [PATCH 23/25] Fixing the link --- .../src/main/resources/META-INF/contracts/main/template.xhtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml index 7669a85..3ada9ce 100644 --- a/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml +++ b/solution/movieplex7-ear/contracts/src/main/resources/META-INF/contracts/main/template.xhtml @@ -59,7 +59,7 @@
-

+

Movieplex 7

@@ -67,7 +67,7 @@
- Book a movie + Book a movie

Chat Room

Movies

Sales From 9617b28791fb797a1faedf4c36e98868aab49248 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 07:51:28 +0100 Subject: [PATCH 24/25] adding a backing bean to display movie and theater total --- .../movieplex7-ear/web/faces-config.NavData | 6 -- .../movieplex7-ear/web/nb-configuration.xml | 19 ------ .../org/javaee7/movieplex7/web/MainPage.java | 58 +++++++++++++++++++ .../web/src/main/webapp/index.xhtml | 2 +- 4 files changed, 59 insertions(+), 26 deletions(-) delete mode 100644 solution/movieplex7-ear/web/faces-config.NavData delete mode 100644 solution/movieplex7-ear/web/nb-configuration.xml create mode 100644 solution/movieplex7-ear/web/src/main/java/org/javaee7/movieplex7/web/MainPage.java diff --git a/solution/movieplex7-ear/web/faces-config.NavData b/solution/movieplex7-ear/web/faces-config.NavData deleted file mode 100644 index 298bfc5..0000000 --- a/solution/movieplex7-ear/web/faces-config.NavData +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/solution/movieplex7-ear/web/nb-configuration.xml b/solution/movieplex7-ear/web/nb-configuration.xml deleted file mode 100644 index 7577ef7..0000000 --- a/solution/movieplex7-ear/web/nb-configuration.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - 1.7-web - WildFly - - 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/index.xhtml b/solution/movieplex7-ear/web/src/main/webapp/index.xhtml index fa7e4f6..d320106 100644 --- a/solution/movieplex7-ear/web/src/main/webapp/index.xhtml +++ b/solution/movieplex7-ear/web/src/main/webapp/index.xhtml @@ -51,7 +51,7 @@ - Showing #{movieFacadeREST.countREST()} movies in #{theaterFacadeREST.countREST()} theaters! + Showing #{mainPage.moviesCount()} movies in #{mainPage.theaterCount()} theaters! From 9f641c9c93f80446f00d545e15e642f9c06efe83 Mon Sep 17 00:00:00 2001 From: arun-gupta Date: Sat, 28 Mar 2015 08:01:07 +0100 Subject: [PATCH 25/25] adding entities dependencies --- solution/movieplex7-ear/web/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/solution/movieplex7-ear/web/pom.xml b/solution/movieplex7-ear/web/pom.xml index 3b7f3cb..1503d57 100644 --- a/solution/movieplex7-ear/web/pom.xml +++ b/solution/movieplex7-ear/web/pom.xml @@ -12,6 +12,13 @@ 1.0-SNAPSHOT war + + + org.javaee7.movieplex7 + entities + + +