├── .gitignore ├── README.md ├── add_ee_kube_pwd_host.sh ├── add_ee_pwd_host.sh ├── add_ee_swarm_pwd_host.sh ├── add_pwd_host.sh ├── docker-compose.yml ├── docker-stack-local.yml ├── docker-stack.yml ├── kube-deployment.yml ├── movieplex7 ├── Dockerfile ├── Dockerfile.wildfly ├── docker-stack.yml ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── org │ │ │ └── javaee7 │ │ │ └── movieplex7 │ │ │ ├── batch │ │ │ ├── SalesBean.java │ │ │ ├── SalesProcessor.java │ │ │ ├── SalesReader.java │ │ │ └── SalesWriter.java │ │ │ ├── booking │ │ │ └── Booking.java │ │ │ ├── chat │ │ │ └── ChatServer.java │ │ │ ├── client │ │ │ ├── MovieBackingBean.java │ │ │ └── MovieClientBean.java │ │ │ ├── entities │ │ │ ├── Movie.java │ │ │ ├── Sales.java │ │ │ ├── ShowTiming.java │ │ │ ├── Theater.java │ │ │ └── Timeslot.java │ │ │ ├── json │ │ │ ├── MovieReader.java │ │ │ └── MovieWriter.java │ │ │ ├── points │ │ │ ├── ReceivePointsBean.java │ │ │ └── SendPointsBean.java │ │ │ └── rest │ │ │ ├── AbstractFacade.java │ │ │ ├── ApplicationConfig.java │ │ │ ├── MovieFacadeREST.java │ │ │ ├── SalesFacadeREST.java │ │ │ ├── ShowTimingFacadeREST.java │ │ │ ├── TheaterFacadeREST.java │ │ │ └── TimeslotFacadeREST.java │ │ ├── resources │ │ └── META-INF │ │ │ ├── batch-jobs │ │ │ └── eod-sales.xml │ │ │ ├── create.sql │ │ │ ├── drop.sql │ │ │ ├── load.sql │ │ │ ├── persistence.xml │ │ │ └── sales.csv │ │ └── webapp │ │ ├── WEB-INF │ │ ├── faces-config.xml │ │ ├── template.xhtml │ │ └── web.xml │ │ ├── batch │ │ └── sales.xhtml │ │ ├── booking │ │ ├── booking-flow.xml │ │ ├── booking.xhtml │ │ ├── confirm.xhtml │ │ ├── print.xhtml │ │ └── showtimes.xhtml │ │ ├── chat │ │ ├── chatroom.xhtml │ │ └── websocket.js │ │ ├── client │ │ ├── addmovie.xhtml │ │ ├── movie.xhtml │ │ └── movies.xhtml │ │ ├── index.xhtml │ │ ├── points │ │ └── points.xhtml │ │ └── resources │ │ └── css │ │ ├── cssLayout.css │ │ └── default.css └── tomcat │ ├── mysql-connector-java-5.1.36-bin.jar │ ├── run.sh │ ├── tomcat-users.xml │ └── web.xml ├── original-solution └── movieplex7-1.0-SNAPSHOT.war └── react-client ├── Dockerfile ├── nginx.conf ├── package.json ├── src ├── .DS_Store ├── app-client.js ├── components │ ├── AppRoutes.js │ ├── IndexPage.js │ ├── Layout.js │ ├── MoviePage.js │ ├── MoviePreview.js │ ├── MoviesMenu.js │ └── NotFoundPage.js ├── data │ ├── movies.js │ └── sales.csv ├── routes.js └── static │ ├── .DS_Store │ ├── css │ └── style.css │ ├── favicon.ico │ ├── img │ ├── BulkResizePhotos.com.html │ ├── avatar.jpg │ ├── banner.jpg │ ├── harry_potter.jpg │ ├── inception.jpg │ ├── inglorious_basterds.jpg │ ├── iron_man.jpg │ ├── kill_bill.jpg │ ├── million_dollar_baby.jpg │ ├── mission_impossible.jpg │ ├── slumdog_millionaire.jpg │ ├── terminator.jpg │ ├── the_bourne_ultimatum.jpg │ ├── the_curious_case_of_benjamin_button.jpg │ ├── the_hangover.jpg │ ├── the_hunger_games.jpg │ ├── the_lord_of_the_rings.jpg │ ├── the_matrix.jpg │ ├── the_pink_panther.jpg │ ├── the_shining.jpg │ ├── titanic.jpg │ └── toy_story.jpg │ ├── index.html │ └── js │ └── bundle.js └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .project 3 | .classpath 4 | .Dockfile.wildfly 5 | /movieplex7/target/ 6 | .settings/ 7 | /react-client/npm-debug.log 8 | /react-client/babel_cache/ 9 | /react-client/node_modules/ 10 | /react-client/yarn.lock 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java EE application migration 2 | 3 | This example demonstrates the path to modernizing a Java EE application to a containerized infrastructure. We'll migrate the [Java EE 7 Hands-on Lab](https://github.com/javaee-samples/javaee7-hol) to Docker. Furthermore, we'll update the presentation layer written in Java Server Faces to a React application. 4 | 5 | ## Dockerizing the Movieplex7 applicaiton 6 | 7 | The repository contains an application for browsing movies along with other related functions. Because we want to update the interface, we'll update the movie entity with extra attributes to make the presentation layer more descriptive. A Docker file builds the application and deploys it in Tomcat EE. 8 | 9 | ## Updating the presentation layer 10 | 11 | The Movieplex7 application includes a REST interface which simplifies updating the presentation layer. We'll use the React javascript framework to build a client that lists the movies and provides more detail about a movie. The client is also compiled and deployed in Docker. 12 | 13 | ## Running the demo 14 | 15 | To run the demo: 16 | 17 | ``` docker-compose up``` 18 | 19 | To run the demo in [Play-with-Docker](http://labs.play-with-docker.com/): 20 | 21 | ``` 22 | git clone https://github.com/dockersamples/javaee-demo.git 23 | 24 | cd javaee-demo 25 | 26 | ./add_pwd_host.sh 27 | 28 | docker-compose up 29 | ``` 30 | -------------------------------------------------------------------------------- /add_ee_kube_pwd_host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PUBLIC_IP=$(ip addr | grep 172.18. | awk '{print $2}' | awk -F / '{print $1}') 4 | API_ENDPOINT="ip${PUBLIC_IP//./-}-${SESSION_ID}.direct.${PWD_HOST_FQDN}:30088" 5 | 6 | sed -i "2i ENV API_HOST=${API_ENDPOINT}" ./react-client/Dockerfile 7 | 8 | -------------------------------------------------------------------------------- /add_ee_pwd_host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PUBLIC_IP=$(ip addr | grep 172.18. | awk '{print $2}' | awk -F / '{print $1}') 4 | API_ENDPOINT="ip${PUBLIC_IP//./-}-${SESSION_ID}.direct.${PWD_HOST_FQDN}:8080" 5 | 6 | sed -i "2i ENV API_HOST=${API_ENDPOINT}" ./react-client/Dockerfile 7 | 8 | -------------------------------------------------------------------------------- /add_ee_swarm_pwd_host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PUBLIC_IP=$(ip addr | grep 172.18. | awk '{print $2}' | awk -F / '{print $1}') 4 | API_ENDPOINT="ip${PUBLIC_IP//./-}-${SESSION_ID}.direct.${PWD_HOST_FQDN}:8080" 5 | 6 | sed -i "2i ENV API_HOST=${API_ENDPOINT}" ./react-client/Dockerfile 7 | 8 | -------------------------------------------------------------------------------- /add_pwd_host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | host_ip=$(hostname -i) 4 | hostname=$(echo $host_ip | sed 's/\./-/g') 5 | FQDN=${PWD_HOST_FQDN} 6 | API_ENDPOINT="pwd$hostname-8080.$FQDN" 7 | 8 | sed -i "2i ENV API_HOST=${API_ENDPOINT}" ./react-client/Dockerfile -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.1" 2 | 3 | services: 4 | movieplex7: 5 | build: 6 | context: ./movieplex7 7 | image: movieplex7-tomee 8 | ports: 9 | - "8080:8080" 10 | networks: 11 | - www 12 | 13 | react-client: 14 | build: 15 | context: ./react-client 16 | image: react-client 17 | ports: 18 | - "80:80" 19 | networks: 20 | - www 21 | 22 | networks: 23 | www: 24 | -------------------------------------------------------------------------------- /docker-stack-local.yml: -------------------------------------------------------------------------------- 1 | version: "3.2" 2 | 3 | services: 4 | movieplex7: 5 | image: dockersamples/movieplex7-tomee 6 | ports: 7 | - "8080:8080" 8 | networks: 9 | - www 10 | deploy: 11 | replicas: 2 12 | update_config: 13 | parallelism: 2 14 | failure_action: rollback 15 | placement: 16 | constraints: 17 | - 'node.role == worker' 18 | restart_policy: 19 | condition: on-failure 20 | delay: 5s 21 | max_attempts: 3 22 | window: 120s 23 | 24 | react-client: 25 | image: dockersamples/react-client 26 | ports: 27 | - "80:3000" 28 | networks: 29 | - www 30 | deploy: 31 | replicas: 2 32 | update_config: 33 | parallelism: 2 34 | failure_action: rollback 35 | placement: 36 | constraints: 37 | - 'node.role == worker' 38 | restart_policy: 39 | condition: on-failure 40 | delay: 5s 41 | max_attempts: 3 42 | window: 120s 43 | 44 | visualizer: 45 | image: dockersamples/visualizer:stable 46 | ports: 47 | - "8001:8080" 48 | stop_grace_period: 1m30s 49 | volumes: 50 | - "/var/run/docker.sock:/var/run/docker.sock" 51 | deploy: 52 | update_config: 53 | failure_action: rollback 54 | placement: 55 | constraints: 56 | - 'node.role == manager' 57 | 58 | 59 | networks: 60 | www: -------------------------------------------------------------------------------- /docker-stack.yml: -------------------------------------------------------------------------------- 1 | version: "3.2" 2 | 3 | services: 4 | movieplex7: 5 | image: dockersamples/movieplex7-tomee 6 | ports: 7 | - "8080:8080" 8 | networks: 9 | - www 10 | deploy: 11 | replicas: 2 12 | update_config: 13 | parallelism: 2 14 | failure_action: rollback 15 | restart_policy: 16 | condition: on-failure 17 | delay: 5s 18 | max_attempts: 3 19 | window: 120s 20 | 21 | react-client: 22 | image: dockersamples/react-client 23 | ports: 24 | - "80:80" 25 | networks: 26 | - www 27 | deploy: 28 | replicas: 2 29 | update_config: 30 | parallelism: 2 31 | failure_action: rollback 32 | restart_policy: 33 | condition: on-failure 34 | delay: 5s 35 | max_attempts: 3 36 | window: 120s 37 | 38 | networks: 39 | www: 40 | -------------------------------------------------------------------------------- /kube-deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | labels: 6 | app: movieplex7 7 | name: movieplex7 8 | spec: 9 | type: NodePort 10 | ports: 11 | - name: movieplex7 12 | port: 8080 13 | nodePort: 30088 14 | selector: 15 | app: movieplex7 16 | --- 17 | apiVersion: apps/v1beta1 18 | kind: Deployment 19 | metadata: 20 | name: movieplex7 21 | labels: 22 | app: movieplex7 23 | spec: 24 | selector: 25 | matchLabels: 26 | app: movieplex7 27 | replicas: 1 28 | template: 29 | metadata: 30 | labels: 31 | app: movieplex7 32 | spec: 33 | containers: 34 | - name: movieplex7 35 | image: /admin/movieplex7-tomee:latest 36 | ports: 37 | - containerPort: 8080 38 | 39 | 40 | --- 41 | apiVersion: v1 42 | kind: Service 43 | metadata: 44 | labels: 45 | app: react-client 46 | name: react-client 47 | spec: 48 | type: NodePort 49 | ports: 50 | - 51 | name: react-client 52 | port: 80 53 | nodePort: 30080 54 | selector: 55 | app: react-client 56 | --- 57 | apiVersion: apps/v1beta1 58 | kind: Deployment 59 | metadata: 60 | name: react-client 61 | labels: 62 | app: react-client 63 | spec: 64 | selector: 65 | matchLabels: 66 | app: react-client 67 | replicas: 1 68 | template: 69 | metadata: 70 | labels: 71 | app: react-client 72 | spec: 73 | containers: 74 | - name: react-client 75 | image: /admin/react-client:latest 76 | env: 77 | - name: API_HOST 78 | value: :30088 79 | ports: 80 | - containerPort: 80 81 | name: react-client 82 | -------------------------------------------------------------------------------- /movieplex7/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:latest AS app 2 | WORKDIR /usr/src/movieplex7 3 | COPY pom.xml . 4 | RUN mvn -B -f pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:resolve 5 | COPY . . 6 | RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml package -DskipTests 7 | 8 | FROM tomee:8-jre-7.0.2-plume 9 | 10 | # tomcat-users.xml sets up user accounts for the Tomcat manager GUI 11 | # and script access for Maven deployments 12 | WORKDIR /usr/local/tomee/ 13 | ADD tomcat/tomcat-users.xml conf/ 14 | ADD tomcat/web.xml conf/ 15 | # copy and deploy application 16 | WORKDIR /usr/local/tomee/webapps/ 17 | COPY --from=app /usr/src/movieplex7/target/movieplex7-1.0-SNAPSHOT.war movieplex7.war 18 | # start tomcat7 19 | EXPOSE 8080 20 | CMD ["catalina.sh", "run"] 21 | -------------------------------------------------------------------------------- /movieplex7/Dockerfile.wildfly: -------------------------------------------------------------------------------- 1 | FROM maven:3-jdk-7 AS app 2 | WORKDIR /usr/src/movieplex7 3 | COPY pom.xml . 4 | RUN mvn -B -f pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:resolve 5 | COPY . . 6 | RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml package -DskipTests 7 | 8 | FROM jboss/wildfly:9.0.2.Final 9 | RUN /opt/jboss/wildfly/bin/add-user.sh admin Admin --silent 10 | WORKDIR /opt/jboss/wildfly/standalone/deployments/ 11 | COPY --from=app /usr/src/movieplex7/target/movieplex7-1.0-SNAPSHOT.war . 12 | EXPOSE 8080 9990 13 | CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"] 14 | -------------------------------------------------------------------------------- /movieplex7/docker-stack.yml: -------------------------------------------------------------------------------- 1 | version: "3.2" 2 | 3 | services: 4 | movieplex7: 5 | image: dockersamples/movieplex7-tomee 6 | ports: 7 | - "8080:8080" 8 | networks: 9 | - www 10 | deploy: 11 | replicas: 2 12 | update_config: 13 | parallelism: 2 14 | failure_action: rollback 15 | restart_policy: 16 | condition: on-failure 17 | delay: 5s 18 | max_attempts: 3 19 | window: 120s 20 | 21 | networks: 22 | www: 23 | -------------------------------------------------------------------------------- /movieplex7/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.glassfish 6 | movieplex7 7 | 1.0-SNAPSHOT 8 | war 9 | 10 | Java EE 7 Hands-on Lab Solution 11 | 12 | 13 | 14 | javax 15 | javaee-api 16 | 7.0 17 | provided 18 | 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-compiler-plugin 26 | 2.3.2 27 | 28 | 1.7 29 | 1.7 30 | 31 | 32 | 33 | org.apache.maven.plugins 34 | maven-war-plugin 35 | 2.1.1 36 | 37 | false 38 | 39 | 40 | 41 | org.wildfly.plugins 42 | wildfly-maven-plugin 43 | 1.0.2.Final 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/batch/SalesBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.batch; 41 | 42 | import java.util.List; 43 | import java.util.Properties; 44 | import javax.batch.operations.JobOperator; 45 | import javax.batch.operations.JobStartException; 46 | import javax.batch.runtime.BatchRuntime; 47 | import javax.enterprise.context.RequestScoped; 48 | import javax.inject.Named; 49 | import javax.persistence.EntityManagerFactory; 50 | import javax.persistence.PersistenceUnit; 51 | import org.javaee7.movieplex7.entities.Sales; 52 | 53 | 54 | /** 55 | * @author Arun Gupta 56 | */ 57 | @Named 58 | @RequestScoped 59 | public class SalesBean { 60 | 61 | @PersistenceUnit EntityManagerFactory em; 62 | 63 | public void runJob() { 64 | try { 65 | JobOperator jo = BatchRuntime.getJobOperator(); 66 | long jobId = jo.start("eod-sales", new Properties()); 67 | System.out.println("Started job: with id: " + jobId); 68 | } catch (JobStartException ex) { 69 | ex.printStackTrace(); 70 | } 71 | } 72 | 73 | public List getSalesData() { 74 | return em.createEntityManager().createNamedQuery("Sales.findAll", Sales.class).getResultList(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/batch/SalesProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.batch; 41 | 42 | import java.util.StringTokenizer; 43 | import javax.batch.api.chunk.ItemProcessor; 44 | import javax.enterprise.context.Dependent; 45 | import javax.inject.Named; 46 | import org.javaee7.movieplex7.entities.Sales; 47 | 48 | /** 49 | * @author Arun Gupta 50 | */ 51 | @Dependent 52 | @Named 53 | public class SalesProcessor implements ItemProcessor { 54 | 55 | @Override 56 | public Sales processItem(Object s) { 57 | Sales sales = new Sales(); 58 | 59 | StringTokenizer tokens = new StringTokenizer((String)s, ","); 60 | sales.setId(Integer.parseInt(tokens.nextToken())); 61 | sales.setAmount(Float.parseFloat(tokens.nextToken())); 62 | 63 | return sales; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/batch/SalesReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.batch; 41 | 42 | import java.io.BufferedReader; 43 | import java.io.IOException; 44 | import java.io.InputStreamReader; 45 | import java.io.Serializable; 46 | import java.util.logging.Level; 47 | import java.util.logging.Logger; 48 | import javax.batch.api.chunk.AbstractItemReader; 49 | import javax.enterprise.context.Dependent; 50 | import javax.inject.Named; 51 | 52 | /** 53 | * @author Arun Gupta 54 | */ 55 | @Dependent 56 | @Named 57 | public class SalesReader extends AbstractItemReader { 58 | 59 | private BufferedReader reader; 60 | 61 | @Override 62 | public void open(Serializable checkpoint) throws Exception { 63 | reader = new BufferedReader( 64 | new InputStreamReader( 65 | Thread.currentThread() 66 | .getContextClassLoader() 67 | .getResourceAsStream("META-INF/sales.csv"))); 68 | } 69 | 70 | @Override 71 | public String readItem() { 72 | String string = null; 73 | try { 74 | string = reader.readLine(); 75 | System.out.println("SalesReader.readItem: " + string); 76 | } catch (IOException ex) { 77 | Logger.getLogger(SalesReader.class.getName()).log(Level.SEVERE, null, ex); 78 | } 79 | return string; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/batch/SalesWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.batch; 41 | 42 | import java.util.List; 43 | import javax.batch.api.chunk.AbstractItemWriter; 44 | import javax.enterprise.context.Dependent; 45 | import javax.inject.Named; 46 | import javax.persistence.EntityManager; 47 | import javax.persistence.PersistenceContext; 48 | import javax.transaction.Transactional; 49 | import org.javaee7.movieplex7.entities.Sales; 50 | 51 | /** 52 | * @author Arun Gupta 53 | */ 54 | @Dependent 55 | @Named 56 | public class SalesWriter extends AbstractItemWriter { 57 | 58 | @PersistenceContext EntityManager em; 59 | 60 | @Override 61 | @Transactional 62 | public void writeItems(List list) { 63 | for (Sales s : (List)list) { 64 | System.out.println("SalesWriter.writeItem: " + s); 65 | em.persist(s); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/booking/Booking.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.booking; 41 | 42 | import java.io.Serializable; 43 | import java.util.List; 44 | import java.util.StringTokenizer; 45 | import javax.faces.flow.FlowScoped; 46 | import javax.inject.Named; 47 | import javax.persistence.EntityManager; 48 | import javax.persistence.NoResultException; 49 | import javax.persistence.PersistenceContext; 50 | import org.javaee7.movieplex7.entities.Movie; 51 | import org.javaee7.movieplex7.entities.ShowTiming; 52 | 53 | /** 54 | * @author Arun Gupta 55 | */ 56 | @Named 57 | @FlowScoped("booking") 58 | public class Booking implements Serializable { 59 | 60 | int movieId; 61 | String startTime; 62 | int startTimeId; 63 | 64 | @PersistenceContext 65 | EntityManager em; 66 | 67 | public int getMovieId() { 68 | return movieId; 69 | } 70 | 71 | public void setMovieId(int movieId) { 72 | this.movieId = movieId; 73 | } 74 | 75 | public String getMovieName() { 76 | try { 77 | return em.createNamedQuery("Movie.findById", Movie.class).setParameter("id", movieId).getSingleResult().getName(); 78 | } catch (NoResultException e) { 79 | return ""; 80 | } 81 | } 82 | 83 | public String getStartTime() { 84 | return startTime; 85 | } 86 | 87 | public void setStartTime(String startTime) { 88 | StringTokenizer tokens = new StringTokenizer(startTime, ","); 89 | startTimeId = Integer.parseInt(tokens.nextToken()); 90 | this.startTime = tokens.nextToken(); 91 | } 92 | 93 | public int getStartTimeId() { 94 | return startTimeId; 95 | } 96 | 97 | public String getName() { 98 | return this.getClass().getSimpleName(); 99 | } 100 | 101 | public String getTheater() { 102 | // for a movie and show 103 | try { 104 | // Always return the first theater 105 | List list = em.createNamedQuery("ShowTiming.findByMovieAndTimingId", ShowTiming.class) 106 | .setParameter("movieId", movieId) 107 | .setParameter("timingId", startTimeId) 108 | .getResultList(); 109 | if (list.isEmpty()) 110 | return "none"; 111 | 112 | return list 113 | .get(0) 114 | .getTheaterId() 115 | .getId().toString(); 116 | } catch (NoResultException e) { 117 | return "none"; 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/chat/ChatServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.chat; 41 | 42 | import java.io.IOException; 43 | import java.util.Collections; 44 | import java.util.HashSet; 45 | import java.util.Set; 46 | import javax.websocket.EncodeException; 47 | import javax.websocket.OnClose; 48 | import javax.websocket.OnMessage; 49 | import javax.websocket.OnOpen; 50 | import javax.websocket.Session; 51 | import javax.websocket.server.ServerEndpoint; 52 | 53 | /** 54 | * @author Arun Gupta 55 | */ 56 | @ServerEndpoint("/websocket") 57 | public class ChatServer { 58 | 59 | private static final Set peers = Collections.synchronizedSet(new HashSet()); 60 | 61 | @OnOpen 62 | public void onOpen(Session peer) { 63 | peers.add(peer); 64 | } 65 | 66 | @OnClose 67 | public void onClose(Session peer) { 68 | peers.remove(peer); 69 | } 70 | 71 | @OnMessage 72 | public void message(String message, Session client) throws IOException, EncodeException { 73 | for (Session peer : peers) { 74 | peer.getBasicRemote().sendText(message); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/client/MovieBackingBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.client; 41 | 42 | import java.io.Serializable; 43 | import javax.enterprise.context.SessionScoped; 44 | import javax.inject.Named; 45 | 46 | /** 47 | * @author Arun Gupta 48 | */ 49 | @Named 50 | @SessionScoped 51 | public class MovieBackingBean implements Serializable { 52 | 53 | int movieId; 54 | String movieName; 55 | String actors; 56 | String poster; 57 | String rating; 58 | String link; 59 | 60 | public int getMovieId() { 61 | return movieId; 62 | } 63 | 64 | public void setMovieId(int mid) { 65 | this.movieId = mid; 66 | } 67 | 68 | public String getMovieName() { 69 | return movieName; 70 | } 71 | 72 | public void setMovieName(String movieName) { 73 | this.movieName = movieName; 74 | } 75 | 76 | public String getActors() { 77 | return actors; 78 | } 79 | 80 | public void setActors(String actors) { 81 | this.actors = actors; 82 | } 83 | 84 | public String getPoster() { 85 | return poster; 86 | } 87 | 88 | public void setPoster(String poster) { 89 | this.poster = poster; 90 | } 91 | 92 | public String getRating() { 93 | return rating; 94 | } 95 | 96 | public void setRating(String rating) { 97 | this.rating = rating; 98 | } 99 | 100 | public String getLink() { 101 | return link; 102 | } 103 | 104 | public void setLink(String link) { 105 | this.link = link; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/client/MovieClientBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.client; 41 | 42 | import javax.annotation.PostConstruct; 43 | import javax.annotation.PreDestroy; 44 | import javax.enterprise.context.RequestScoped; 45 | import javax.inject.Inject; 46 | import javax.inject.Named; 47 | import javax.servlet.http.HttpServletRequest; 48 | import javax.ws.rs.client.Client; 49 | import javax.ws.rs.client.ClientBuilder; 50 | import javax.ws.rs.client.Entity; 51 | import javax.ws.rs.client.WebTarget; 52 | import javax.ws.rs.core.MediaType; 53 | import org.javaee7.movieplex7.entities.Movie; 54 | import org.javaee7.movieplex7.json.MovieWriter; 55 | 56 | /** 57 | * @author Arun Gupta 58 | */ 59 | @Named 60 | @RequestScoped 61 | public class MovieClientBean { 62 | 63 | @Inject 64 | MovieBackingBean bean; 65 | 66 | Client client; 67 | WebTarget target; 68 | 69 | @Inject HttpServletRequest httpServletRequest; 70 | 71 | @PostConstruct 72 | public void init() { 73 | client = ClientBuilder.newClient(); 74 | target = client 75 | .target("http://" + 76 | httpServletRequest.getLocalName() + 77 | ":" + 78 | httpServletRequest.getLocalPort() + 79 | "/" + 80 | httpServletRequest.getContextPath() + 81 | "/webresources/movie/"); 82 | } 83 | 84 | @PreDestroy 85 | public void destroy() { 86 | client.close(); 87 | } 88 | 89 | public Movie[] getMovies() { 90 | return target 91 | .request() 92 | .get(Movie[].class); 93 | } 94 | 95 | public Movie getMovie() { 96 | Movie m = target 97 | .path("{movie}") 98 | .resolveTemplate("movie", bean.getMovieId()) 99 | .request() 100 | .get(Movie.class); 101 | return m; 102 | } 103 | 104 | public Movie getMovieJson() { 105 | Movie m = target 106 | .path("{movie}") 107 | .resolveTemplate("movie", bean.getMovieId()) 108 | .request(MediaType.APPLICATION_JSON) 109 | .get(Movie.class); 110 | return m; 111 | } 112 | 113 | public void addMovie() { 114 | Movie m = new Movie(); 115 | m.setId(bean.getMovieId()); 116 | m.setName(bean.getMovieName()); 117 | m.setActors(bean.getActors()); 118 | target 119 | .register(MovieWriter.class) 120 | .request() 121 | .post(Entity.entity(m, MediaType.APPLICATION_JSON)); 122 | } 123 | 124 | public void deleteMovie() { 125 | target 126 | .path("{movieId}") 127 | .resolveTemplate("movieId", bean.getMovieId()) 128 | .request() 129 | .delete(); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/entities/Movie.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.entities; 41 | 42 | import java.io.Serializable; 43 | import java.util.Collection; 44 | import javax.persistence.CascadeType; 45 | import javax.persistence.Entity; 46 | import javax.persistence.Id; 47 | import javax.persistence.NamedQueries; 48 | import javax.persistence.NamedQuery; 49 | import javax.persistence.OneToMany; 50 | import javax.persistence.Table; 51 | import javax.validation.constraints.NotNull; 52 | import javax.validation.constraints.Size; 53 | import javax.xml.bind.annotation.XmlRootElement; 54 | import javax.xml.bind.annotation.XmlTransient; 55 | 56 | /** 57 | * @author Arun Gupta 58 | */ 59 | @Entity 60 | @Table(name = "MOVIE") 61 | @XmlRootElement 62 | @NamedQueries({ 63 | @NamedQuery(name = "Movie.findAll", query = "SELECT m FROM Movie m"), 64 | @NamedQuery(name = "Movie.findById", query = "SELECT m FROM Movie m WHERE m.id = :id"), 65 | @NamedQuery(name = "Movie.findByName", query = "SELECT m FROM Movie m WHERE m.name = :name"), 66 | @NamedQuery(name = "Movie.findByActors", query = "SELECT m FROM Movie m WHERE m.actors = :actors")}) 67 | public class Movie implements Serializable { 68 | private static final long serialVersionUID = 1L; 69 | @Id 70 | @NotNull 71 | private Integer id; 72 | 73 | @NotNull 74 | @Size(min = 1, max = 50) 75 | private String name; 76 | 77 | @NotNull 78 | @Size(min = 1, max = 200) 79 | private String actors; 80 | 81 | @NotNull 82 | @Size(min = 1, max = 200) 83 | private String poster; 84 | 85 | @NotNull 86 | @Size(min = 1, max = 4) 87 | private String rating; 88 | 89 | @NotNull 90 | @Size(min = 1, max = 200) 91 | private String link; 92 | 93 | @OneToMany(cascade = CascadeType.ALL, mappedBy = "movieId") 94 | private Collection showTimingCollection; 95 | 96 | public Movie() { 97 | } 98 | 99 | public Movie(Integer id) { 100 | this.id = id; 101 | } 102 | 103 | public Movie(Integer id, String name, String actors, String poster, String rating, String link) { 104 | this.id = id; 105 | this.name = name; 106 | this.actors = actors; 107 | this.poster = poster; 108 | this.rating = rating; 109 | this.link = link; 110 | } 111 | 112 | public Integer getId() { 113 | return id; 114 | } 115 | 116 | public void setId(Integer id) { 117 | this.id = id; 118 | } 119 | 120 | public String getName() { 121 | return name; 122 | } 123 | 124 | public void setName(String name) { 125 | this.name = name; 126 | } 127 | 128 | public String getActors() { 129 | return actors; 130 | } 131 | 132 | public void setActors(String actors) { 133 | this.actors = actors; 134 | } 135 | 136 | public String getPoster() { 137 | return poster; 138 | } 139 | 140 | public void setPoster(String poster) { 141 | this.poster = poster; 142 | } 143 | 144 | public String getRating() { 145 | return rating; 146 | } 147 | 148 | public void setRating(String rating) { 149 | this.rating = rating; 150 | } 151 | 152 | public String getLink() { 153 | return link; 154 | } 155 | 156 | public void setLink(String link) { 157 | this.link = link; 158 | } 159 | 160 | @XmlTransient 161 | public Collection getShowTimingCollection() { 162 | return showTimingCollection; 163 | } 164 | 165 | public void setShowTimingCollection(Collection showTimingCollection) { 166 | this.showTimingCollection = showTimingCollection; 167 | } 168 | 169 | @Override 170 | public int hashCode() { 171 | int hash = 0; 172 | hash += (id != null ? id.hashCode() : 0); 173 | return hash; 174 | } 175 | 176 | @Override 177 | public boolean equals(Object object) { 178 | // TODO: Warning - this method won't work in the case the id fields are not set 179 | if (!(object instanceof Movie)) { 180 | return false; 181 | } 182 | Movie other = (Movie) object; 183 | if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { 184 | return false; 185 | } 186 | return true; 187 | } 188 | 189 | @Override 190 | public String toString() { 191 | return name; 192 | } 193 | 194 | } 195 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/entities/Sales.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package org.javaee7.movieplex7.entities; 42 | 43 | import java.io.Serializable; 44 | import javax.persistence.Basic; 45 | import javax.persistence.Column; 46 | import javax.persistence.Entity; 47 | import javax.persistence.Id; 48 | import javax.persistence.JoinColumn; 49 | import javax.persistence.NamedQueries; 50 | import javax.persistence.NamedQuery; 51 | import javax.persistence.OneToOne; 52 | import javax.persistence.Table; 53 | import javax.validation.constraints.NotNull; 54 | import javax.xml.bind.annotation.XmlRootElement; 55 | 56 | /** 57 | * @author Arun Gupta 58 | */ 59 | @Entity 60 | @Table(name = "SALES") 61 | @XmlRootElement 62 | @NamedQueries({ 63 | @NamedQuery(name = "Sales.findAll", query = "SELECT s FROM Sales s"), 64 | @NamedQuery(name = "Sales.findById", query = "SELECT s FROM Sales s WHERE s.id = :id"), 65 | @NamedQuery(name = "Sales.findByAmount", query = "SELECT s FROM Sales s WHERE s.amount = :amount")}) 66 | public class Sales implements Serializable { 67 | private static final long serialVersionUID = 1L; 68 | @Id 69 | @Basic(optional = false) 70 | @NotNull 71 | @Column(name = "ID") 72 | private Integer id; 73 | @Basic(optional = false) 74 | @NotNull 75 | @Column(name = "AMOUNT") 76 | private double amount; 77 | 78 | // @JoinColumn(name = "ID", referencedColumnName = "ID", insertable = false, updatable = false) 79 | // @OneToOne(optional = false) 80 | // private Timeslot timeslot; 81 | 82 | public Sales() { 83 | } 84 | 85 | public Sales(Integer id) { 86 | this.id = id; 87 | } 88 | 89 | public Sales(Integer id, double amount) { 90 | this.id = id; 91 | this.amount = amount; 92 | } 93 | 94 | public Integer getId() { 95 | return id; 96 | } 97 | 98 | public void setId(Integer id) { 99 | this.id = id; 100 | } 101 | 102 | public double getAmount() { 103 | return amount; 104 | } 105 | 106 | public void setAmount(double amount) { 107 | this.amount = amount; 108 | } 109 | 110 | // public Timeslot getTimeslot() { 111 | // return timeslot; 112 | // } 113 | // 114 | // public void setTimeslot(Timeslot timeslot) { 115 | // this.timeslot = timeslot; 116 | // } 117 | 118 | @Override 119 | public int hashCode() { 120 | int hash = 0; 121 | hash += (id != null ? id.hashCode() : 0); 122 | return hash; 123 | } 124 | 125 | @Override 126 | public boolean equals(Object object) { 127 | // TODO: Warning - this method won't work in the case the id fields are not set 128 | if (!(object instanceof Sales)) { 129 | return false; 130 | } 131 | Sales other = (Sales) object; 132 | if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { 133 | return false; 134 | } 135 | return true; 136 | } 137 | 138 | @Override 139 | public String toString() { 140 | return "foo.Sales[ id=" + id + " ]"; 141 | } 142 | 143 | } 144 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/entities/ShowTiming.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.entities; 41 | 42 | import java.io.Serializable; 43 | import javax.persistence.Column; 44 | import javax.persistence.Entity; 45 | import javax.persistence.Id; 46 | import javax.persistence.JoinColumn; 47 | import javax.persistence.ManyToOne; 48 | import javax.persistence.NamedQueries; 49 | import javax.persistence.NamedQuery; 50 | import javax.persistence.Table; 51 | import javax.validation.constraints.NotNull; 52 | import javax.xml.bind.annotation.XmlRootElement; 53 | 54 | /** 55 | * @author ArunGupta 56 | */ 57 | @Entity 58 | @Table(name = "SHOW_TIMING") 59 | @XmlRootElement 60 | @NamedQueries({ 61 | @NamedQuery(name = "ShowTiming.findAll", query = "SELECT s FROM ShowTiming s"), 62 | @NamedQuery(name = "ShowTiming.findById", query = "SELECT s FROM ShowTiming s WHERE s.id = :id"), 63 | @NamedQuery(name = "ShowTiming.findByMovieAndTimingId", query = "SELECT s FROM ShowTiming s WHERE s.movieId.id = :movieId AND s.timingId.id = :timingId"), 64 | @NamedQuery(name = "ShowTiming.findByDay", query = "SELECT s FROM ShowTiming s WHERE s.day = :day")}) 65 | public class ShowTiming implements Serializable { 66 | 67 | private static final long serialVersionUID = 1L; 68 | @Id 69 | @NotNull 70 | private Integer id; 71 | 72 | @NotNull 73 | private int day; 74 | 75 | @JoinColumn(name = "TIMING_ID", referencedColumnName = "ID") 76 | @ManyToOne(optional = false) 77 | private Timeslot timingId; 78 | 79 | @JoinColumn(name = "THEATER_ID", referencedColumnName = "ID") 80 | @ManyToOne(optional = false) 81 | private Theater theaterId; 82 | 83 | @JoinColumn(name = "MOVIE_ID", referencedColumnName = "ID") 84 | @ManyToOne(optional = false) 85 | private Movie movieId; 86 | 87 | public ShowTiming() { 88 | } 89 | 90 | public ShowTiming(Integer id) { 91 | this.id = id; 92 | } 93 | 94 | public ShowTiming(Integer id, int day) { 95 | this.id = id; 96 | this.day = day; 97 | } 98 | 99 | public Integer getId() { 100 | return id; 101 | } 102 | 103 | public void setId(Integer id) { 104 | this.id = id; 105 | } 106 | 107 | public int getDay() { 108 | return day; 109 | } 110 | 111 | public void setDay(int day) { 112 | this.day = day; 113 | } 114 | 115 | public Timeslot getTimingId() { 116 | return timingId; 117 | } 118 | 119 | public void setTimingId(Timeslot timingId) { 120 | this.timingId = timingId; 121 | } 122 | 123 | public Theater getTheaterId() { 124 | return theaterId; 125 | } 126 | 127 | public void setTheaterId(Theater theaterId) { 128 | this.theaterId = theaterId; 129 | } 130 | 131 | public Movie getMovieId() { 132 | return movieId; 133 | } 134 | 135 | public void setMovieId(Movie movieId) { 136 | this.movieId = movieId; 137 | } 138 | 139 | @Override 140 | public int hashCode() { 141 | int hash = 0; 142 | hash += (id != null ? id.hashCode() : 0); 143 | return hash; 144 | } 145 | 146 | @Override 147 | public boolean equals(Object object) { 148 | // TODO: Warning - this method won't work in the case the id fields are not set 149 | if (!(object instanceof ShowTiming)) { 150 | return false; 151 | } 152 | ShowTiming other = (ShowTiming) object; 153 | if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { 154 | return false; 155 | } 156 | return true; 157 | } 158 | 159 | @Override 160 | public String toString() { 161 | return movieId.getName() + ", " + timingId.getStartTime(); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/entities/Theater.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.entities; 41 | 42 | import java.io.Serializable; 43 | import java.util.Collection; 44 | import javax.persistence.CascadeType; 45 | import javax.persistence.Entity; 46 | import javax.persistence.Id; 47 | import javax.persistence.NamedQueries; 48 | import javax.persistence.NamedQuery; 49 | import javax.persistence.OneToMany; 50 | import javax.persistence.Table; 51 | import javax.validation.constraints.NotNull; 52 | import javax.xml.bind.annotation.XmlRootElement; 53 | import javax.xml.bind.annotation.XmlTransient; 54 | 55 | /** 56 | * @author Arun Gupta 57 | */ 58 | @Entity 59 | @Table(name = "THEATER") 60 | @XmlRootElement 61 | @NamedQueries({ 62 | @NamedQuery(name = "Theater.findAll", query = "SELECT t FROM Theater t"), 63 | @NamedQuery(name = "Theater.findById", query = "SELECT t FROM Theater t WHERE t.id = :id"), 64 | @NamedQuery(name = "Theater.findByCapacity", query = "SELECT t FROM Theater t WHERE t.capacity = :capacity")}) 65 | public class Theater implements Serializable { 66 | private static final long serialVersionUID = 1L; 67 | @Id 68 | @NotNull 69 | private Integer id; 70 | 71 | @NotNull 72 | private int capacity; 73 | 74 | @OneToMany(cascade = CascadeType.ALL, mappedBy = "theaterId") 75 | private Collection showTimingCollection; 76 | 77 | public Theater() { 78 | } 79 | 80 | public Theater(Integer id) { 81 | this.id = id; 82 | } 83 | 84 | public Theater(Integer id, int capacity) { 85 | this.id = id; 86 | this.capacity = capacity; 87 | } 88 | 89 | public Integer getId() { 90 | return id; 91 | } 92 | 93 | public void setId(Integer id) { 94 | this.id = id; 95 | } 96 | 97 | public int getCapacity() { 98 | return capacity; 99 | } 100 | 101 | public void setCapacity(int capacity) { 102 | this.capacity = capacity; 103 | } 104 | 105 | @XmlTransient 106 | public Collection getShowTimingCollection() { 107 | return showTimingCollection; 108 | } 109 | 110 | public void setShowTimingCollection(Collection showTimingCollection) { 111 | this.showTimingCollection = showTimingCollection; 112 | } 113 | 114 | @Override 115 | public int hashCode() { 116 | int hash = 0; 117 | hash += (id != null ? id.hashCode() : 0); 118 | return hash; 119 | } 120 | 121 | @Override 122 | public boolean equals(Object object) { 123 | // TODO: Warning - this method won't work in the case the id fields are not set 124 | if (!(object instanceof Theater)) { 125 | return false; 126 | } 127 | Theater other = (Theater) object; 128 | if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { 129 | return false; 130 | } 131 | return true; 132 | } 133 | 134 | @Override 135 | public String toString() { 136 | return "foo.Theater[ id=" + id + " ]"; 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/entities/Timeslot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.entities; 41 | 42 | import java.io.Serializable; 43 | import java.util.Collection; 44 | import javax.persistence.CascadeType; 45 | import javax.persistence.Column; 46 | import javax.persistence.Entity; 47 | import javax.persistence.Id; 48 | import javax.persistence.NamedQueries; 49 | import javax.persistence.NamedQuery; 50 | import javax.persistence.OneToMany; 51 | import javax.persistence.Table; 52 | import javax.validation.constraints.NotNull; 53 | import javax.validation.constraints.Size; 54 | import javax.xml.bind.annotation.XmlRootElement; 55 | import javax.xml.bind.annotation.XmlTransient; 56 | 57 | /** 58 | * @author Arun Gupta 59 | */ 60 | @Entity 61 | @Table(name = "TIMESLOT") 62 | @XmlRootElement 63 | @NamedQueries({ 64 | @NamedQuery(name = "Timeslot.findAll", query = "SELECT t FROM Timeslot t"), 65 | @NamedQuery(name = "Timeslot.findById", query = "SELECT t FROM Timeslot t WHERE t.id = :id"), 66 | @NamedQuery(name = "Timeslot.findByStartTime", query = "SELECT t FROM Timeslot t WHERE t.startTime = :startTime"), 67 | @NamedQuery(name = "Timeslot.findByEndTime", query = "SELECT t FROM Timeslot t WHERE t.endTime = :endTime")}) 68 | public class Timeslot implements Serializable { 69 | private static final long serialVersionUID = 1L; 70 | @Id 71 | @NotNull 72 | private Integer id; 73 | 74 | @NotNull 75 | @Size(min = 1, max = 5) 76 | @Column(name = "START_TIME") 77 | private String startTime; 78 | 79 | @NotNull 80 | @Size(min = 1, max = 5) 81 | @Column(name = "END_TIME") 82 | private String endTime; 83 | 84 | @OneToMany(cascade = CascadeType.ALL, mappedBy = "timingId") 85 | private Collection showTimingCollection; 86 | 87 | public Timeslot() { 88 | } 89 | 90 | public Timeslot(Integer id) { 91 | this.id = id; 92 | } 93 | 94 | public Timeslot(Integer id, String startTime, String endTime) { 95 | this.id = id; 96 | this.startTime = startTime; 97 | this.endTime = endTime; 98 | } 99 | 100 | public Integer getId() { 101 | return id; 102 | } 103 | 104 | public void setId(Integer id) { 105 | this.id = id; 106 | } 107 | 108 | public String getStartTime() { 109 | return startTime; 110 | } 111 | 112 | public void setStartTime(String startTime) { 113 | this.startTime = startTime; 114 | } 115 | 116 | public String getEndTime() { 117 | return endTime; 118 | } 119 | 120 | public void setEndTime(String endTime) { 121 | this.endTime = endTime; 122 | } 123 | 124 | @XmlTransient 125 | public Collection getShowTimingCollection() { 126 | return showTimingCollection; 127 | } 128 | 129 | public void setShowTimingCollection(Collection showTimingCollection) { 130 | this.showTimingCollection = showTimingCollection; 131 | } 132 | 133 | @Override 134 | public int hashCode() { 135 | int hash = 0; 136 | hash += (id != null ? id.hashCode() : 0); 137 | return hash; 138 | } 139 | 140 | @Override 141 | public boolean equals(Object object) { 142 | // TODO: Warning - this method won't work in the case the id fields are not set 143 | if (!(object instanceof Timeslot)) { 144 | return false; 145 | } 146 | Timeslot other = (Timeslot) object; 147 | if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { 148 | return false; 149 | } 150 | return true; 151 | } 152 | 153 | @Override 154 | public String toString() { 155 | return startTime; 156 | } 157 | 158 | } 159 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/json/MovieReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package org.javaee7.movieplex7.json; 42 | 43 | import java.io.IOException; 44 | import java.io.InputStream; 45 | import java.lang.annotation.Annotation; 46 | import java.lang.reflect.Type; 47 | import javax.json.Json; 48 | import javax.json.stream.JsonParser; 49 | import static javax.json.stream.JsonParser.Event.KEY_NAME; 50 | import javax.ws.rs.Consumes; 51 | import javax.ws.rs.WebApplicationException; 52 | import javax.ws.rs.core.MediaType; 53 | import javax.ws.rs.core.MultivaluedMap; 54 | import javax.ws.rs.ext.MessageBodyReader; 55 | import javax.ws.rs.ext.Provider; 56 | import org.javaee7.movieplex7.entities.Movie; 57 | 58 | /** 59 | * @author Arun Gupta 60 | */ 61 | @Provider 62 | @Consumes(MediaType.APPLICATION_JSON) 63 | public class MovieReader implements MessageBodyReader { 64 | 65 | @Override 66 | public boolean isReadable(Class type, Type type1, Annotation[] antns, MediaType mt) { 67 | return Movie.class.isAssignableFrom(type); 68 | } 69 | 70 | @Override 71 | public Movie readFrom(Class type, Type type1, Annotation[] antns, MediaType mt, MultivaluedMap mm, InputStream in) throws IOException, WebApplicationException { 72 | Movie movie = new Movie(); 73 | JsonParser parser = Json.createParser(in); 74 | while (parser.hasNext()) { 75 | switch (parser.next()) { 76 | case KEY_NAME: 77 | String key = parser.getString(); 78 | parser.next(); 79 | switch (key) { 80 | case "id": 81 | movie.setId(parser.getInt()); 82 | break; 83 | case "name": 84 | movie.setName(parser.getString()); 85 | break; 86 | case "actors": 87 | movie.setActors(parser.getString()); 88 | break; 89 | case "poster": 90 | movie.setPoster(parser.getString()); 91 | break; 92 | case "rating": 93 | movie.setRating(parser.getString()); 94 | break; 95 | case "link": 96 | movie.setLink(parser.getString()); 97 | break; 98 | default: 99 | break; 100 | } 101 | break; 102 | default: 103 | break; 104 | } 105 | } 106 | return movie; 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/json/MovieWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package org.javaee7.movieplex7.json; 42 | 43 | import java.io.IOException; 44 | import java.io.OutputStream; 45 | import java.lang.annotation.Annotation; 46 | import java.lang.reflect.Type; 47 | import javax.json.Json; 48 | import javax.json.stream.JsonGenerator; 49 | import javax.ws.rs.Produces; 50 | import javax.ws.rs.WebApplicationException; 51 | import javax.ws.rs.core.MediaType; 52 | import javax.ws.rs.core.MultivaluedMap; 53 | import javax.ws.rs.ext.MessageBodyWriter; 54 | import javax.ws.rs.ext.Provider; 55 | import org.javaee7.movieplex7.entities.Movie; 56 | 57 | /** 58 | * @author Arun Gupta 59 | */ 60 | @Provider 61 | @Produces(MediaType.APPLICATION_JSON) 62 | public class MovieWriter implements MessageBodyWriter { 63 | 64 | @Override 65 | public boolean isWriteable(Class type, Type type1, Annotation[] antns, MediaType mt) { 66 | return Movie.class.isAssignableFrom(type); 67 | } 68 | 69 | @Override 70 | public long getSize(Movie t, Class type, Type type1, Annotation[] antns, MediaType mt) { 71 | // As of JAX-RS 2.0, the method has been deprecated and the 72 | // value returned by the method is ignored by a JAX-RS runtime. 73 | // All MessageBodyWriter implementations are advised to return -1 from 74 | // the method. 75 | 76 | return -1; 77 | } 78 | 79 | @Override 80 | public void writeTo(Movie t, Class type, Type type1, Annotation[] antns, MediaType mt, MultivaluedMap mm, OutputStream out) throws IOException, WebApplicationException { 81 | JsonGenerator gen = Json.createGenerator(out); 82 | gen.writeStartObject() 83 | .write("id", t.getId()) 84 | .write("name", t.getName()) 85 | .write("actors", t.getActors()) 86 | .write("poster", t.getPoster()) 87 | .write("rating", t.getRating()) 88 | .write("link", t.getLink()) 89 | .writeEnd(); 90 | gen.flush(); 91 | 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/points/ReceivePointsBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.points; 41 | 42 | import java.util.Enumeration; 43 | import java.util.logging.Level; 44 | import java.util.logging.Logger; 45 | import javax.annotation.Resource; 46 | import javax.enterprise.context.RequestScoped; 47 | import javax.inject.Inject; 48 | import javax.inject.Named; 49 | import javax.jms.JMSConsumer; 50 | import javax.jms.JMSContext; 51 | import javax.jms.JMSDestinationDefinition; 52 | import javax.jms.JMSException; 53 | import javax.jms.Queue; 54 | import javax.jms.QueueBrowser; 55 | 56 | /** 57 | * @author Arun Gupta 58 | */ 59 | @JMSDestinationDefinition(name = "java:global/jms/pointsQueue", 60 | interfaceName = "javax.jms.Queue") 61 | @Named 62 | @RequestScoped 63 | public class ReceivePointsBean { 64 | 65 | @Inject 66 | // @JMSConnectionFactory("java:comp/DefaultJMSConnectionFactory") 67 | JMSContext context; 68 | 69 | @Resource(lookup = "java:global/jms/pointsQueue") 70 | Queue pointsQueue; 71 | 72 | public String receiveMessage() { 73 | try (JMSConsumer consumer = context.createConsumer(pointsQueue)) { 74 | String message = consumer.receiveBody(String.class); 75 | System.out.println("Received message: " + message); 76 | return message; 77 | } 78 | } 79 | 80 | public int getQueueSize() { 81 | int count = 0; 82 | try { 83 | QueueBrowser browser = context.createBrowser(pointsQueue); 84 | Enumeration elems = browser.getEnumeration(); 85 | while (elems.hasMoreElements()) { 86 | elems.nextElement(); 87 | count++; 88 | } 89 | } catch (JMSException ex) { 90 | Logger.getLogger(ReceivePointsBean.class.getName()).log(Level.SEVERE, null, ex); 91 | } 92 | System.out.println("Getting queue size: " + count); 93 | return count; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/points/SendPointsBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.points; 41 | 42 | import javax.annotation.Resource; 43 | import javax.enterprise.context.RequestScoped; 44 | import javax.inject.Inject; 45 | import javax.inject.Named; 46 | import javax.jms.JMSContext; 47 | import javax.jms.Queue; 48 | import javax.validation.constraints.NotNull; 49 | import javax.validation.constraints.Pattern; 50 | 51 | /** 52 | * @author Arun Gupta 53 | */ 54 | @Named 55 | @RequestScoped 56 | public class SendPointsBean { 57 | 58 | @Inject 59 | // @JMSConnectionFactory("java:comp/DefaultJMSConnectionFactory") 60 | JMSContext context; 61 | 62 | @NotNull 63 | @Pattern(regexp = "^\\d{2},\\d{2}", message = "Message format must be 2 digits, comma, 2 digits, e.g. 12,12") 64 | private String message; 65 | 66 | public String getMessage() { 67 | return message; 68 | } 69 | 70 | public void setMessage(String message) { 71 | this.message = message; 72 | } 73 | 74 | @Resource(lookup = "java:global/jms/pointsQueue") 75 | Queue pointsQueue; 76 | 77 | public void sendMessage() { 78 | System.out.println("Sending message: " + message); 79 | 80 | context.createProducer().send(pointsQueue, message); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/rest/AbstractFacade.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.rest; 41 | 42 | import java.util.List; 43 | import javax.persistence.EntityManager; 44 | 45 | /** 46 | * @author Arun Gupta 47 | */ 48 | public abstract class AbstractFacade { 49 | private Class entityClass; 50 | 51 | public AbstractFacade(Class entityClass) { 52 | this.entityClass = entityClass; 53 | } 54 | 55 | protected abstract EntityManager getEntityManager(); 56 | 57 | public void create(T entity) { 58 | getEntityManager().persist(entity); 59 | } 60 | 61 | public void edit(Object id) { 62 | T t = getEntityManager().find(entityClass, id); 63 | getEntityManager().merge(t); 64 | } 65 | 66 | public void remove(T entity) { 67 | getEntityManager().remove(getEntityManager().merge(entity)); 68 | } 69 | 70 | public T find(Object id) { 71 | return getEntityManager().find(entityClass, id); 72 | } 73 | 74 | public List getAll() { 75 | javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery(); 76 | cq.select(cq.from(entityClass)); 77 | return getEntityManager().createQuery(cq).getResultList(); 78 | } 79 | 80 | public List findRange(int[] range) { 81 | javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery(); 82 | cq.select(cq.from(entityClass)); 83 | javax.persistence.Query q = getEntityManager().createQuery(cq); 84 | q.setMaxResults(range[1] - range[0]); 85 | q.setFirstResult(range[0]); 86 | return q.getResultList(); 87 | } 88 | 89 | public int count() { 90 | javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery(); 91 | javax.persistence.criteria.Root rt = cq.from(entityClass); 92 | cq.select(getEntityManager().getCriteriaBuilder().count(rt)); 93 | javax.persistence.Query q = getEntityManager().createQuery(cq); 94 | return ((Long) q.getSingleResult()).intValue(); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/rest/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.rest; 41 | 42 | import java.util.Set; 43 | import javax.ws.rs.core.Application; 44 | 45 | /** 46 | * @author Arun Gupta 47 | */ 48 | @javax.ws.rs.ApplicationPath("webresources") 49 | public class ApplicationConfig extends Application { 50 | 51 | @Override 52 | public Set> getClasses() { 53 | Set> resources = new java.util.HashSet<>(); 54 | addRestResourceClasses(resources); 55 | return resources; 56 | } 57 | 58 | /** 59 | * Do not modify addRestResourceClasses() method. 60 | * It is automatically re-generated by NetBeans REST support to populate 61 | * given list with all resources defined in the project. 62 | */ 63 | private void addRestResourceClasses(Set> resources) { 64 | resources.add(org.javaee7.movieplex7.json.MovieReader.class); 65 | resources.add(org.javaee7.movieplex7.json.MovieWriter.class); 66 | resources.add(org.javaee7.movieplex7.rest.MovieFacadeREST.class); 67 | resources.add(org.javaee7.movieplex7.rest.SalesFacadeREST.class); 68 | resources.add(org.javaee7.movieplex7.rest.ShowTimingFacadeREST.class); 69 | resources.add(org.javaee7.movieplex7.rest.TheaterFacadeREST.class); 70 | resources.add(org.javaee7.movieplex7.rest.TimeslotFacadeREST.class); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/rest/MovieFacadeREST.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.rest; 41 | 42 | import java.util.List; 43 | import javax.ejb.Stateless; 44 | import javax.inject.Named; 45 | import javax.persistence.EntityManager; 46 | import javax.persistence.PersistenceContext; 47 | import javax.ws.rs.Consumes; 48 | import javax.ws.rs.DELETE; 49 | import javax.ws.rs.GET; 50 | import javax.ws.rs.POST; 51 | import javax.ws.rs.PUT; 52 | import javax.ws.rs.Path; 53 | import javax.ws.rs.PathParam; 54 | import javax.ws.rs.Produces; 55 | import org.javaee7.movieplex7.entities.Movie; 56 | 57 | /** 58 | * @author Arun Gupta 59 | */ 60 | @Named 61 | @Stateless 62 | @Path("movie") 63 | public class MovieFacadeREST extends AbstractFacade { 64 | @PersistenceContext 65 | protected EntityManager em; 66 | 67 | public MovieFacadeREST() { 68 | super(Movie.class); 69 | } 70 | 71 | @POST 72 | @Override 73 | @Consumes({"application/xml", "application/json"}) 74 | public void create(Movie entity) { 75 | super.create(entity); 76 | } 77 | 78 | @PUT 79 | @Path("{id}") 80 | public void edit(@PathParam("id") Integer id) { 81 | super.edit(id); 82 | } 83 | 84 | @DELETE 85 | @Path("{id}") 86 | public void remove(@PathParam("id") Integer id) { 87 | super.remove(super.find(id)); 88 | } 89 | 90 | @GET 91 | @Path("{id}") 92 | @Produces({"application/xml", "application/json"}) 93 | public Movie find(@PathParam("id") Integer id) { 94 | return super.find(id); 95 | } 96 | 97 | @GET 98 | @Override 99 | @Produces({"application/xml", "application/json"}) 100 | public List getAll() { 101 | return super.getAll(); 102 | } 103 | 104 | @GET 105 | @Path("{from}/{to}") 106 | @Produces({"application/xml", "application/json"}) 107 | public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) { 108 | return super.findRange(new int[]{from, to}); 109 | } 110 | 111 | @GET 112 | @Path("count") 113 | @Produces("text/plain") 114 | public String countREST() { 115 | return String.valueOf(super.count()); 116 | } 117 | 118 | @Override 119 | protected EntityManager getEntityManager() { 120 | return em; 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/rest/SalesFacadeREST.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.rest; 41 | 42 | import java.util.List; 43 | import javax.ejb.Stateless; 44 | import javax.inject.Named; 45 | import javax.persistence.EntityManager; 46 | import javax.persistence.PersistenceContext; 47 | import javax.ws.rs.Consumes; 48 | import javax.ws.rs.DELETE; 49 | import javax.ws.rs.GET; 50 | import javax.ws.rs.POST; 51 | import javax.ws.rs.PUT; 52 | import javax.ws.rs.Path; 53 | import javax.ws.rs.PathParam; 54 | import javax.ws.rs.Produces; 55 | import org.javaee7.movieplex7.entities.Sales; 56 | import org.javaee7.movieplex7.entities.Timeslot; 57 | 58 | /** 59 | * @author Arun Gupta 60 | */ 61 | @Named 62 | @Stateless 63 | @Path("sales") 64 | public class SalesFacadeREST extends AbstractFacade { 65 | @PersistenceContext 66 | private EntityManager em; 67 | 68 | public SalesFacadeREST() { 69 | super(Sales.class); 70 | } 71 | 72 | @POST 73 | @Override 74 | @Consumes({"application/xml", "application/json"}) 75 | public void create(Sales entity) { 76 | super.create(entity); 77 | } 78 | 79 | @PUT 80 | @Path("{id}") 81 | public void edit(@PathParam("id") Integer id) { 82 | super.edit(id); 83 | } 84 | 85 | @DELETE 86 | @Path("{id}") 87 | public void remove(@PathParam("id") Integer id) { 88 | super.remove(super.find(id)); 89 | } 90 | 91 | @GET 92 | @Path("{id}") 93 | @Produces({"application/xml", "application/json"}) 94 | public Sales find(@PathParam("id") Integer id) { 95 | return super.find(id); 96 | } 97 | 98 | @GET 99 | @Override 100 | @Produces({"application/xml", "application/json"}) 101 | public List getAll() { 102 | return super.getAll(); 103 | } 104 | 105 | @GET 106 | @Path("{from}/{to}") 107 | @Produces({"application/xml", "application/json"}) 108 | public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) { 109 | return super.findRange(new int[]{from, to}); 110 | } 111 | 112 | @GET 113 | @Path("count") 114 | @Produces("text/plain") 115 | public String countREST() { 116 | return String.valueOf(super.count()); 117 | } 118 | 119 | @Override 120 | protected EntityManager getEntityManager() { 121 | return em; 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/rest/ShowTimingFacadeREST.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.rest; 41 | 42 | import java.util.List; 43 | import javax.ejb.Stateless; 44 | import javax.inject.Named; 45 | import javax.persistence.EntityManager; 46 | import javax.persistence.PersistenceContext; 47 | import javax.ws.rs.Consumes; 48 | import javax.ws.rs.DELETE; 49 | import javax.ws.rs.GET; 50 | import javax.ws.rs.POST; 51 | import javax.ws.rs.PUT; 52 | import javax.ws.rs.Path; 53 | import javax.ws.rs.PathParam; 54 | import javax.ws.rs.Produces; 55 | import org.javaee7.movieplex7.entities.ShowTiming; 56 | 57 | /** 58 | * @author Arun Gupta 59 | */ 60 | @Named 61 | @Stateless 62 | @Path("showtiming") 63 | public class ShowTimingFacadeREST extends AbstractFacade { 64 | @PersistenceContext 65 | private EntityManager em; 66 | 67 | public ShowTimingFacadeREST() { 68 | super(ShowTiming.class); 69 | } 70 | 71 | @POST 72 | @Override 73 | @Consumes({"application/xml", "application/json"}) 74 | public void create(ShowTiming entity) { 75 | super.create(entity); 76 | } 77 | 78 | @PUT 79 | @Path("{id}") 80 | public void edit(@PathParam("id") Integer id) { 81 | super.edit(id); 82 | } 83 | 84 | @DELETE 85 | @Path("{id}") 86 | public void remove(@PathParam("id") Integer id) { 87 | super.remove(super.find(id)); 88 | } 89 | 90 | @GET 91 | @Path("{id}") 92 | @Produces({"application/xml", "application/json"}) 93 | public ShowTiming find(@PathParam("id") Integer id) { 94 | return super.find(id); 95 | } 96 | 97 | @GET 98 | @Override 99 | @Produces({"application/xml", "application/json"}) 100 | public List getAll() { 101 | return super.getAll(); 102 | } 103 | 104 | @GET 105 | @Path("{from}/{to}") 106 | @Produces({"application/xml", "application/json"}) 107 | public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) { 108 | return super.findRange(new int[]{from, to}); 109 | } 110 | 111 | @GET 112 | @Path("count") 113 | @Produces("text/plain") 114 | public String countREST() { 115 | return String.valueOf(super.count()); 116 | } 117 | 118 | @Override 119 | protected EntityManager getEntityManager() { 120 | return em; 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/rest/TheaterFacadeREST.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.rest; 41 | 42 | import java.util.List; 43 | import javax.ejb.Stateless; 44 | import javax.inject.Named; 45 | import javax.persistence.EntityManager; 46 | import javax.persistence.PersistenceContext; 47 | import javax.ws.rs.Consumes; 48 | import javax.ws.rs.DELETE; 49 | import javax.ws.rs.GET; 50 | import javax.ws.rs.POST; 51 | import javax.ws.rs.PUT; 52 | import javax.ws.rs.Path; 53 | import javax.ws.rs.PathParam; 54 | import javax.ws.rs.Produces; 55 | import org.javaee7.movieplex7.entities.Theater; 56 | 57 | /** 58 | * @author Arun Gupta 59 | */ 60 | @Named 61 | @Stateless 62 | @Path("theater") 63 | public class TheaterFacadeREST extends AbstractFacade { 64 | @PersistenceContext 65 | private EntityManager em; 66 | 67 | public TheaterFacadeREST() { 68 | super(Theater.class); 69 | } 70 | 71 | @POST 72 | @Override 73 | @Consumes({"application/xml", "application/json"}) 74 | public void create(Theater entity) { 75 | super.create(entity); 76 | } 77 | 78 | @PUT 79 | @Path("{id}") 80 | public void edit(@PathParam("id") Integer id) { 81 | super.edit(id); 82 | } 83 | 84 | @DELETE 85 | @Path("{id}") 86 | public void remove(@PathParam("id") Integer id) { 87 | super.remove(super.find(id)); 88 | } 89 | 90 | @GET 91 | @Path("{id}") 92 | @Produces({"application/xml", "application/json"}) 93 | public Theater find(@PathParam("id") Integer id) { 94 | return super.find(id); 95 | } 96 | 97 | @GET 98 | @Override 99 | @Produces({"application/xml", "application/json"}) 100 | public List getAll() { 101 | return super.getAll(); 102 | } 103 | 104 | @GET 105 | @Path("{from}/{to}") 106 | @Produces({"application/xml", "application/json"}) 107 | public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) { 108 | return super.findRange(new int[]{from, to}); 109 | } 110 | 111 | @GET 112 | @Path("count") 113 | @Produces("text/plain") 114 | public String countREST() { 115 | return String.valueOf(super.count()); 116 | } 117 | 118 | @Override 119 | protected EntityManager getEntityManager() { 120 | return em; 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /movieplex7/src/main/java/org/javaee7/movieplex7/rest/TimeslotFacadeREST.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | package org.javaee7.movieplex7.rest; 41 | 42 | import java.util.List; 43 | import javax.ejb.Stateless; 44 | import javax.inject.Named; 45 | import javax.persistence.EntityManager; 46 | import javax.persistence.PersistenceContext; 47 | import javax.ws.rs.Consumes; 48 | import javax.ws.rs.DELETE; 49 | import javax.ws.rs.GET; 50 | import javax.ws.rs.POST; 51 | import javax.ws.rs.PUT; 52 | import javax.ws.rs.Path; 53 | import javax.ws.rs.PathParam; 54 | import javax.ws.rs.Produces; 55 | import org.javaee7.movieplex7.entities.Timeslot; 56 | 57 | /** 58 | * @author Arun Gupta 59 | */ 60 | @Named 61 | @Stateless 62 | @Path("timeslot") 63 | public class TimeslotFacadeREST extends AbstractFacade { 64 | @PersistenceContext 65 | private EntityManager em; 66 | 67 | public TimeslotFacadeREST() { 68 | super(Timeslot.class); 69 | } 70 | 71 | @POST 72 | @Override 73 | @Consumes({"application/xml", "application/json"}) 74 | public void create(Timeslot entity) { 75 | super.create(entity); 76 | } 77 | 78 | @PUT 79 | @Path("{id}") 80 | public void edit(@PathParam("id") Integer id) { 81 | super.edit(id); 82 | } 83 | 84 | @DELETE 85 | @Path("{id}") 86 | public void remove(@PathParam("id") Integer id) { 87 | super.remove(super.find(id)); 88 | } 89 | 90 | @GET 91 | @Path("{id}") 92 | @Produces({"application/xml", "application/json"}) 93 | public Timeslot find(@PathParam("id") Integer id) { 94 | return super.find(id); 95 | } 96 | 97 | @GET 98 | @Override 99 | @Produces({"application/xml", "application/json"}) 100 | public List getAll() { 101 | return super.getAll(); 102 | } 103 | 104 | @GET 105 | @Path("{from}/{to}") 106 | @Produces({"application/xml", "application/json"}) 107 | public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) { 108 | return super.findRange(new int[]{from, to}); 109 | } 110 | 111 | @GET 112 | @Path("count") 113 | @Produces("text/plain") 114 | public String countREST() { 115 | return String.valueOf(super.count()); 116 | } 117 | 118 | @Override 119 | protected EntityManager getEntityManager() { 120 | return em; 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /movieplex7/src/main/resources/META-INF/batch-jobs/eod-sales.xml: -------------------------------------------------------------------------------- 1 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /movieplex7/src/main/resources/META-INF/create.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE THEATER ("ID" INTEGER not null primary key, "CAPACITY" INTEGER not null) 2 | CREATE TABLE MOVIE("ID" INTEGER not null primary key, "NAME" VARCHAR(50) not null, "ACTORS" VARCHAR(200) not null,"POSTER" VARCHAR(200),"RATING" VARCHAR(4), "LINK" VARCHAR(200)) 3 | CREATE TABLE TIMESLOT("ID" INTEGER not null primary key, "START_TIME" VARCHAR(5) not null, "END_TIME" VARCHAR(5) not null) 4 | 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) 5 | CREATE TABLE SALES("ID" INTEGER not null primary key, "AMOUNT" FLOAT not null) 6 | CREATE TABLE POINTS("ID" INTEGER not null primary key, "POINTS" INTEGER not null) 7 | ALTER TABLE SHOW_TIMING ADD CONSTRAINT SHOW_THEATER_FK FOREIGN KEY ("THEATER_ID") REFERENCES THEATER ("ID") 8 | ALTER TABLE SHOW_TIMING ADD CONSTRAINT SHOW_MOVIE_FK FOREIGN KEY ("MOVIE_ID") REFERENCES MOVIE ("ID") 9 | ALTER TABLE SHOW_TIMING ADD CONSTRAINT TIMESLOT_FK FOREIGN KEY ("TIMING_ID") REFERENCES TIMESLOT ("ID") 10 | ALTER TABLE SALES ADD CONSTRAINT SHOW_TIMING_ID_FK FOREIGN KEY ("ID") REFERENCES SHOW_TIMING ("ID") -------------------------------------------------------------------------------- /movieplex7/src/main/resources/META-INF/drop.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE SALES 2 | DROP TABLE POINTS 3 | DROP TABLE SHOW_TIMING 4 | DROP TABLE MOVIE 5 | DROP TABLE TIMESLOT 6 | DROP TABLE THEATER -------------------------------------------------------------------------------- /movieplex7/src/main/resources/META-INF/load.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO THEATER("ID", "CAPACITY") VALUES (1, 50) 2 | INSERT INTO THEATER("ID", "CAPACITY") VALUES (2, 70) 3 | INSERT INTO THEATER("ID", "CAPACITY") VALUES (3, 70) 4 | INSERT INTO THEATER("ID", "CAPACITY") VALUES (4, 60) 5 | INSERT INTO THEATER("ID", "CAPACITY") VALUES (5, 120) 6 | INSERT INTO THEATER("ID", "CAPACITY") VALUES (6, 100) 7 | INSERT INTO THEATER("ID", "CAPACITY") VALUES (7, 80) 8 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (1, 'The Matrix', 'Keanu Reeves, Laurence Fishburne, Carrie-Ann Moss', 'the_matrix.jpg', '8.7','http://www.imdb.com/title/tt0133093/') 9 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (2, 'The Lord of The Rings', 'Elijah Wood, Ian Mckellen, Viggo Mortensen', 'the_lord_of_the_rings.jpg', '8.8', 'http://www.imdb.com/title/tt0120737/') 10 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (3, 'Inception', 'Leonardo DiCaprio', 'inception.jpg', '8.8', 'http://www.imdb.com/title/tt1375666/') 11 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (4, 'The Shining', 'Jack Nicholson, Shelley Duvall', 'the_shining.jpg', '8.4', 'http://www.imdb.com/title/tt0081505/') 12 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (5, 'Mission Impossible', 'Tom Cruise, Jeremy Renner','mission_impossible.jpg', '7.1', 'http://www.imdb.com/title/tt0258463/') 13 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (6, 'Terminator', 'Arnold Schwarzenegger, Linda Hamilton', 'terminator.jpg', '8.0', 'http://www.imdb.com/title/tt0088247/') 14 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (7, 'Titanic', 'Leonardo DiCaprio, Kate Winslet', 'titanic.jpg', '7.7', 'http://www.imdb.com/title/tt0120338/') 15 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (8, 'Iron Man', 'Robert Downey Jr, Gwyneth Paltrow, Terrence Howard', 'iron_man.jpg', '7.9', 'http://www.imdb.com/title/tt0371746/') 16 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (9, 'Inglorious Bastards', 'Brad Pitt, Diane Kruger', 'inglorious_basterds.jpg', '8.3', 'http://www.imdb.com/title/tt0361748/') 17 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (10, 'Million Dollar Baby', 'Hillary Swank, Client Eastwood', 'million_dollar_baby.jpg', '8.1', 'http://www.imdb.com/title/tt0405159/') 18 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (11, 'Kill Bill', 'Uma Thurman', 'kill_bill.jpg', '8.1', 'http://www.imdb.com/title/tt0266697/') 19 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (12, 'The Hunger Games', 'Jennifer Lawrence', 'the_hunger_games.jpg', '7.2', 'http://www.imdb.com/title/tt1392170/') 20 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (13, 'The Hangover', 'Bradley Cooper, Zach Galifianakis', 'the_hangover.jpg', '7.8', 'http://www.imdb.com/title/tt1119646/') 21 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (14, 'Toy Story', 'Tom Hanks, Michael Keaton', 'toy_story.jpg', '7.3', 'http://www.imdb.com/title/tt0114709/') 22 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (15, 'Harry Potter', 'Daniel Radcliffe, Emma Watson', 'harry_potter.jpg', '7.5', 'http://www.imdb.com/title/tt0241527/') 23 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (16, 'Avatar', 'Sam Worthington, Sigourney Weaver', 'avatar.jpg', '7.8','http://www.imdb.com/title/tt0499549/') 24 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (17, 'Slumdog Millionaire', 'Anil Kapoor, Dev Patel, Freida Pinto', 'slumdog_millionaire.jpg', '8.0', 'http://www.imdb.com/title/tt1010048/') 25 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (18, 'The Curious Case of Benjamin Button', 'Brad Pitt, Cate Blanchett', 'the_curious_case_of_benjamin_button.jpg', '7.8', 'http://www.imdb.com/title/tt0421715/') 26 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (19, 'The Bourne Ultimatum', 'Matt Damon, Julia Stiles', 'the_bourne_ultimatum.jpg', '8.1', 'http://www.imdb.com/title/tt0440963/') 27 | INSERT INTO MOVIE("ID", "NAME", "ACTORS", "POSTER", "RATING", "LINK") VALUES (20, 'The Pink Panther', 'Steve Martin, Kevin Kline', 'the_pink_panther.jpg', '7.2', 'http://www.imdb.com/title/tt0057413/') 28 | INSERT INTO TIMESLOT("ID", "START_TIME", "END_TIME") VALUES (1, '10:00', '11:45') 29 | INSERT INTO TIMESLOT("ID", "START_TIME", "END_TIME") VALUES (2, '12:00', '01:45') 30 | INSERT INTO TIMESLOT("ID", "START_TIME", "END_TIME") VALUES (3, '02:00', '03:45') 31 | INSERT INTO TIMESLOT("ID", "START_TIME", "END_TIME") VALUES (4, '04:00', '05:45') 32 | INSERT INTO TIMESLOT("ID", "START_TIME", "END_TIME") VALUES (5, '06:00', '07:45') 33 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (1, 1, 1, 1, 1) 34 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (2, 1, 1, 2, 2) 35 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (3, 1, 1, 3, 3) 36 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (4, 1, 1, 4, 4) 37 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (5, 1, 1, 5, 5) 38 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (6, 1, 2, 6, 1) 39 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (7, 1, 2, 7, 2) 40 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (8, 1, 2, 8, 3) 41 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (9, 1, 2, 9, 4) 42 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (10, 1, 2, 10, 5) 43 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (11, 1, 3, 11, 1) 44 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (12, 1, 3, 12, 2) 45 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (13, 1, 3, 13, 3) 46 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (14, 1, 3, 14, 4) 47 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (15, 1, 3, 15, 5) 48 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (16, 1, 4, 16, 1) 49 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (17, 1, 4, 17, 2) 50 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (18, 1, 4, 18, 3) 51 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (19, 1, 4, 19, 4) 52 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (20, 1, 4, 20, 5) 53 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (21, 1, 5, 1, 1) 54 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (22, 1, 5, 2, 2) 55 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (23, 1, 5, 3, 3) 56 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (24, 1, 5, 4, 4) 57 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (25, 1, 5, 5, 5) 58 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (26, 1, 6, 6, 1) 59 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (27, 1, 6, 7, 2) 60 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (28, 1, 6, 8, 3) 61 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (29, 1, 6, 9, 4) 62 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (30, 1, 6, 10, 5) 63 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (31, 1, 7, 11, 1) 64 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (32, 1, 7, 12, 2) 65 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (33, 1, 7, 13, 3) 66 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (34, 1, 7, 14, 4) 67 | INSERT INTO SHOW_TIMING("ID", "DAY", "THEATER_ID", "MOVIE_ID", "TIMING_ID") VALUES (35, 1, 7, 15, 5) 68 | -------------------------------------------------------------------------------- /movieplex7/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /movieplex7/src/main/resources/META-INF/sales.csv: -------------------------------------------------------------------------------- 1 | 1,500.00 2 | 2,660.00 3 | 3,80.00 4 | 4,470.00 5 | 5,1100.x0 6 | 6,240.00 7 | 7,1000.00 8 | 8,2300.00 9 | 9,230.00 10 | 10,600.00 11 | 11,800.00 12 | 12,1400.00 13 | 13,780.00 14 | 14,890.00 15 | 15,490.00 16 | 16,670.00 17 | 17,450.x0 18 | 18,1230.00 19 | 19,700.00 20 | 20,900.00 -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/WEB-INF/template.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | 53 | Movieplex 7 54 | 55 | 56 | 57 | 58 | 59 |
60 | 61 | 62 |

63 |
64 | 72 |
73 |
74 |
75 |
76 | 77 | 78 | Book a movie 79 |

Chat Room 80 |

Movies 81 |

Sales 82 |

Points 83 | 84 | 85 |

86 |
87 | Content 88 |
89 |
90 |
91 | 92 | 93 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 45 | javax.faces.PROJECT_STAGE 46 | Development 47 | 48 | 49 | javax.faces.CLIENT_WINDOW_MODE 50 | url 51 | 52 | 53 | Faces Servlet 54 | javax.faces.webapp.FacesServlet 55 | 1 56 | 57 | 58 | Faces Servlet 59 | /faces/* 60 | 61 | 62 | faces/index.xhtml 63 | 64 | 65 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/batch/sales.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |

Movie Sales

55 | 56 | 57 | 58 | 59 | 60 | 61 | #{s.id} 62 | 63 | 64 | 65 | 66 | 67 | #{s.amount} 68 | 69 | 70 | 71 | 72 | 73 | 74 |
75 | 76 |
77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/booking/booking-flow.xml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 49 | 50 | 51 | 52 | /index 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/booking/booking.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |

Pick a movie

56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
67 | 68 |
69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/booking/confirm.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |

No theater found, choose a different time

58 | 59 | Movie name: #{booking.movieName}

60 | Starts at: #{booking.startTime}

61 |

62 | 63 | 64 | 65 |

Confirm ?

66 | 67 | 68 | Movie name: #{booking.movieName}

69 | Starts at: #{booking.startTime}

70 | Theater: #{booking.theater}

71 |

72 |

73 |
74 | 75 |
76 | 77 |
78 | 79 |
80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/booking/print.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |

Reservation Confirmed

55 | 56 | 57 | Movie name: #{booking.movieName}

58 | Starts at: #{booking.startTime}

59 | Theater: #{booking.theater}

60 | 61 |

62 |
63 |
64 | 65 |
66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/booking/showtimes.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Show Timings for #{booking.movieName}

15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/chat/chatroom.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
53 | 54 | 55 | 56 | 60 | 64 | 65 | 66 | 72 | 73 |
57 | Chat Log
58 | 59 |
61 | Users
62 | 63 |
67 | 68 | 69 |

70 | 71 |

74 | 75 |
76 |
77 | 78 | 79 |
80 | 81 |
82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/chat/websocket.js: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | var wsUri = 'ws://' + document.location.host 42 | + document.location.pathname.substr(0, document.location.pathname.indexOf("/faces")) 43 | + '/websocket'; 44 | console.log(wsUri); 45 | var websocket = new WebSocket(wsUri); 46 | 47 | var username; 48 | websocket.onopen = function(evt) { onOpen(evt); }; 49 | websocket.onmessage = function(evt) { onMessage(evt); }; 50 | websocket.onerror = function(evt) { onError(evt); }; 51 | websocket.onclose = function(evt) { onClose(evt); }; 52 | var output = document.getElementById("output"); 53 | var textField = document.getElementById("textField"); 54 | var users = document.getElementById("users"); 55 | var chatlog = document.getElementById("chatlog"); 56 | 57 | function join() { 58 | username = textField.value; 59 | websocket.send(username + " joined"); 60 | } 61 | 62 | function send_message() { 63 | websocket.send(username + ": " + textField.value); 64 | } 65 | 66 | function onOpen() { 67 | writeToScreen("CONNECTED"); 68 | } 69 | 70 | function onClose() { 71 | writeToScreen("DISCONNECTED"); 72 | } 73 | 74 | function onMessage(evt) { 75 | writeToScreen("RECEIVED: " + evt.data); 76 | if (evt.data.indexOf("joined") !== -1) { 77 | users.innerHTML += evt.data.substring(0, evt.data.indexOf(" joined")) + "\n"; 78 | } else { 79 | chatlog.innerHTML += evt.data + "\n"; 80 | } 81 | } 82 | 83 | function onError(evt) { 84 | writeToScreen('ERROR: ' + evt.data); 85 | } 86 | 87 | function disconnect() { 88 | websocket.close(); 89 | } 90 | 91 | function writeToScreen(message) { 92 | var pre = document.createElement("p"); 93 | pre.style.wordWrap = "break-word"; 94 | pre.innerHTML = message; 95 | output.appendChild(pre); 96 | } 97 | 98 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/client/addmovie.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |

Add a New Movie

54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
Movie Id:
Movie Name:
Movie Actors:
70 | 71 |
72 |
73 | 74 |
75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/client/movie.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |

Movie Details

54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
Movie Id:#{movieClientBean.movie.id}
Movie Name:#{movieClientBean.movie.name}
Movie Actors:#{movieClientBean.movie.actors}
70 | 71 |
72 |
73 | 74 |
75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/client/movies.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |

List of Movies

57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 |
69 | 70 |
71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/index.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Showing #{movieFacadeREST.countREST()} movies in #{theaterFacadeREST.countREST()} theaters! 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/points/points.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |

Points

54 | 55 | 56 | Queue size:

57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/resources/css/cssLayout.css: -------------------------------------------------------------------------------- 1 | 2 | #top { 3 | position: relative; 4 | background-color: #036fab; 5 | color: white; 6 | padding: 5px; 7 | margin: 0px 0px 10px 0px; 8 | } 9 | 10 | #bottom { 11 | position: relative; 12 | background-color: #c2dfef; 13 | padding: 5px; 14 | margin: 10px 0px 0px 0px; 15 | } 16 | 17 | #left { 18 | float: left; 19 | background-color: #ece3a5; 20 | padding: 5px; 21 | width: 150px; 22 | } 23 | 24 | #right { 25 | float: right; 26 | background-color: #ece3a5; 27 | padding: 5px; 28 | width: 150px; 29 | } 30 | 31 | .center_content { 32 | position: relative; 33 | background-color: #dddddd; 34 | padding: 5px; 35 | } 36 | 37 | .left_content { 38 | background-color: #dddddd; 39 | padding: 5px; 40 | margin-left: 170px; 41 | } 42 | 43 | .right_content { 44 | background-color: #dddddd; 45 | padding: 5px; 46 | margin: 0px 170px 0px 170px; 47 | } 48 | 49 | #top a:link, #top a:visited { 50 | color: white; 51 | font-weight : bold; 52 | text-decoration: none; 53 | } 54 | 55 | #top a:link:hover, #top a:visited:hover { 56 | color: black; 57 | font-weight : bold; 58 | text-decoration : underline; 59 | } 60 | 61 | 62 | -------------------------------------------------------------------------------- /movieplex7/src/main/webapp/resources/css/default.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #ffffff; 3 | font-size: 12px; 4 | font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; 5 | color: #000000; 6 | margin: 10px; 7 | } 8 | 9 | h1 { 10 | font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; 11 | border-bottom: 1px solid #AFAFAF; 12 | font-size: 16px; 13 | font-weight: bold; 14 | margin: 0px; 15 | padding: 0px; 16 | color: #D20005; 17 | } 18 | 19 | a:link, a:visited { 20 | color: #045491; 21 | font-weight : bold; 22 | text-decoration: none; 23 | } 24 | 25 | a:link:hover, a:visited:hover { 26 | color: #045491; 27 | font-weight : bold; 28 | text-decoration : underline; 29 | } 30 | -------------------------------------------------------------------------------- /movieplex7/tomcat/mysql-connector-java-5.1.36-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/movieplex7/tomcat/mysql-connector-java-5.1.36-bin.jar -------------------------------------------------------------------------------- /movieplex7/tomcat/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec ${CATALINA_HOME}/bin/catalina.sh jpda run 4 | -------------------------------------------------------------------------------- /movieplex7/tomcat/tomcat-users.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /original-solution/movieplex7-1.0-SNAPSHOT.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/original-solution/movieplex7-1.0-SNAPSHOT.war -------------------------------------------------------------------------------- /react-client/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:latest AS build 2 | WORKDIR /usr/src/react-client 3 | COPY package.json . 4 | RUN npm install 5 | COPY . . 6 | RUN npm run build 7 | 8 | FROM nginx:alpine 9 | COPY nginx.conf /etc/nginx/conf.d/default.conf 10 | COPY --from=build /usr/src/react-client/src/static /usr/share/nginx/html 11 | -------------------------------------------------------------------------------- /react-client/nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name localhost; 4 | 5 | location / { 6 | root /usr/share/nginx/html; 7 | index index.html index.htm; 8 | 9 | # Put all requests to index.html, since React Router is using clean URLs 10 | try_files $uri /index.html; 11 | } 12 | 13 | error_page 500 502 503 504 /50x.html; 14 | location = /50x.html { 15 | root /usr/share/nginx/html; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /react-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-moviplex7", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "NODE_ENV=production ./node_modules/.bin/http-server -p 3000 src/static", 8 | "build": "NODE_ENV=production ./node_modules/.bin/webpack --color -p --progress" 9 | }, 10 | "author": "", 11 | "license": "MIT", 12 | "dependencies": { 13 | "babel-cli": "^6.11.4", 14 | "babel-core": "^6.13.2", 15 | "babel-preset-es2015": "^6.13.2", 16 | "babel-preset-react": "^6.11.1", 17 | "csvtojson": "^1.1.7", 18 | "ejs": "^2.5.7", 19 | "env-cmd": "^7.0.0", 20 | "express": "^4.14.1", 21 | "file-exists": "^5.0.0", 22 | "http-server": "^0.9.0", 23 | "react": "^15.3.2", 24 | "react-dom": "^15.3.2", 25 | "react-router": "^2.6.1", 26 | "xmljson": "^0.2.0", 27 | "webpack": "^2.1.0" 28 | }, 29 | "devDependencies": { 30 | "babel-loader": "^6.2.10", 31 | "http-server": "^0.9.0" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /react-client/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/.DS_Store -------------------------------------------------------------------------------- /react-client/src/app-client.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import AppRoutes from './components/AppRoutes'; 4 | 5 | window.onload = () => { 6 | ReactDOM.render(, document.getElementById('main')); 7 | }; 8 | -------------------------------------------------------------------------------- /react-client/src/components/AppRoutes.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Router, browserHistory } from 'react-router'; 3 | import routes from '../routes'; 4 | 5 | export default class AppRoutes extends React.Component { 6 | render() { 7 | return ( 8 | window.scrollTo(0, 0)}/> 9 | ); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /react-client/src/components/IndexPage.js: -------------------------------------------------------------------------------- 1 | // src/components/IndexPage.js 2 | import React from 'react'; 3 | import MoviePreview from './MoviePreview'; 4 | import MoviePage from './MoviePage'; 5 | 6 | var API_HOST = process.env.API_HOST; 7 | var REQUEST_URL = `http://${API_HOST}/movieplex7/webresources/movie/`; 8 | var parseXml = require('xmljson').to_json; 9 | 10 | console.log(process.env); 11 | console.log(REQUEST_URL); 12 | 13 | function status(response) { 14 | if (response.ok) { 15 | return Promise.resolve(response) 16 | } else { 17 | return Promise.reject(new Error('fail')).then(function(error){ 18 | console.log(error); 19 | }, function(error){ 20 | console.log(error); 21 | }); 22 | } 23 | } 24 | 25 | function clone(response) { 26 | return response.clone(); 27 | } 28 | 29 | function text(response) { 30 | return response.text() 31 | } 32 | 33 | function parseToJson(response) { 34 | var movielist = []; 35 | parseXml(response, function (error, data){ 36 | for (var key in data.movies.movie){ 37 | movielist.push(data.movies.movie[key]); 38 | } 39 | }); 40 | return(movielist); 41 | } 42 | 43 | export default class IndexPage extends React.Component { 44 | 45 | constructor(props, context) { 46 | super(props, context); 47 | this.state = { 48 | movies : null 49 | }; 50 | } 51 | 52 | componentDidMount() { 53 | if (API_HOST === null && window.location.host.indexOf('play') > 0) { 54 | REQUEST_URL = "http://" + window.location.host.replace("-80", "-8080")+"/movieplex7/webresources/movie/"; 55 | }; 56 | console.log(REQUEST_URL); 57 | fetch(REQUEST_URL, {mode: 'cors'}) 58 | .then(status) 59 | .then(clone) 60 | .then(text) 61 | .then(parseToJson) 62 | .then((movies) => {this.setState({ movies }); 63 | }); 64 | } 65 | 66 | render() { 67 | if(!this.state.movies){ 68 | return

Loading ...
69 | } 70 | return ( 71 |
72 |
73 | {this.state.movies.map(movieData => )} 74 |
75 |
76 | ); 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /react-client/src/components/Layout.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'react-router'; 3 | 4 | export default class Layout extends React.Component { 5 | render() { 6 | return ( 7 |
8 |
9 | 10 |
11 | 12 |
MOVIEPLEX 7
13 |
14 | 15 |
16 |
{this.props.children}
17 |
18 |

19 | Client application for JavaEE Movieplex MTA example 20 |

21 |
22 |
23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /react-client/src/components/MoviePage.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'react-router'; 3 | import NotFoundPage from './NotFoundPage'; 4 | import MoviesMenu from './MoviesMenu'; 5 | 6 | var API_HOST = process.env.API_HOST; 7 | var REQUEST_URL = `http://${API_HOST}/movieplex7/webresources/movie/`; 8 | var parseXml = require('xmljson').to_json; 9 | 10 | function status(response) { 11 | if (response.ok) { 12 | return Promise.resolve(response) 13 | } else { 14 | return Promise.reject(new Error('fail')).then(function(error){ 15 | console.log(error); 16 | }, function(error){ 17 | console.log(error); 18 | }); 19 | } 20 | } 21 | 22 | function clone(response) { 23 | return response.clone(); 24 | } 25 | 26 | function text(response) { 27 | return response.text() 28 | } 29 | 30 | function parseToJson(response) { 31 | console.log('MoviePage response to JSON'); 32 | var movielist = []; 33 | parseXml(response, function (error, data){ 34 | console.log(data); 35 | for (var key in data.movies.movie){ 36 | movielist.push(data.movies.movie[key]); 37 | } 38 | console.log("list: ", movielist.toString()); 39 | }); 40 | 41 | return(movielist); 42 | } 43 | 44 | export default class MoviePage extends React.Component { 45 | constructor(props, context) { 46 | super(props, context); 47 | this.state = { 48 | movies: [] 49 | }; 50 | } 51 | 52 | componentDidMount() { 53 | this.MovieList(); 54 | } 55 | 56 | MovieList(){ 57 | if (API_HOST === null && window.location.host.indexOf('play') > 0) { 58 | REQUEST_URL = "http://" + window.location.host.replace("-80", "-8080")+"/movieplex7/webresources/movie/"; 59 | }; 60 | 61 | return ( 62 | fetch(REQUEST_URL, {mode: 'cors'}) 63 | .then(status) 64 | .then(clone) 65 | .then(text) 66 | .then(parseToJson) 67 | .then((movies) => {this.setState({ movies }) 68 | }) 69 | ) 70 | } 71 | 72 | render() { 73 | const { movies } = this.state; 74 | const id = this.props.params.id; 75 | const movie = movies.filter((movie) => movie.id == id)[0] 76 | if (!movie) { 77 | return ; 78 | } 79 | const headerStyle = { backgroundImage: `url(/img/banner.jpg)` }; 80 | return ( 81 |
82 | 83 |
84 |
85 |
86 | 87 |

{movie.name}

88 |
89 |
90 | Cast: {movie.actors}
91 | Rating: {movie.rating}
92 | (Find out more on IMDB). 93 |
94 |
95 |
96 | « Back to the index 97 |
98 |
99 | ); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /react-client/src/components/MoviePreview.js: -------------------------------------------------------------------------------- 1 | // src/components/AthletePreview.js 2 | import React from 'react'; 3 | import { Link } from 'react-router'; 4 | import MoviePage from './MoviePage'; 5 | 6 | export default class MoviePreview extends React.Component { 7 | render() { 8 | return ( 9 | 10 | 11 |
12 | 13 |

{this.props.name}

14 |
15 | 16 | ); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /react-client/src/components/MoviesMenu.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'react-router'; 3 | 4 | export default class MoviesMenu extends React.Component { 5 | render() { 6 | return ( 7 | 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /react-client/src/components/NotFoundPage.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'react-router'; 3 | 4 | export default class NotFoundPage extends React.Component { 5 | render() { 6 | return ( 7 |
8 |

404

9 |

Page not found!

10 |

11 | Go back to the main page 12 |

13 |
14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /react-client/src/data/movies.js: -------------------------------------------------------------------------------- 1 | const movies = [ 2 | { 3 | "actors": "Keanu Reeves, Laurence Fishburne, Carrie-Ann Moss", 4 | "id": "1", 5 | "name": "The Matrix", 6 | "poster" : "the_matrix.jpeg", 7 | "rating" : 8.7, 8 | "link" : "http://www.imdb.com/title/tt0133093/" 9 | }, 10 | { 11 | "actors": "Elijah Wood, Ian Mckellen, Viggo Mortensen", 12 | "id": "2", 13 | "name": "The Lord of The Rings", 14 | "poster" : "the_lord_of_the_rings.jpeg", 15 | "rating" : 8.8, 16 | "link" : "http://www.imdb.com/title/tt0120737/" 17 | }, 18 | { 19 | "actors": "Leonardo DiCaprio", 20 | "id": "3", 21 | "name": "Inception", 22 | "poster" : "inception.jpeg", 23 | "rating" : 8.8, 24 | "link" : "http://www.imdb.com/title/tt1375666/" 25 | }, 26 | { 27 | "actors": "Jack Nicholson, Shelley Duvall", 28 | "id": "4", 29 | "name": "The Shining", 30 | "poster" : "the_shining.jpeg", 31 | "rating" : 8.4, 32 | "link" : "http://www.imdb.com/title/tt0081505/" 33 | }, 34 | { 35 | "actors": "Tom Cruise, Jeremy Renner", 36 | "id": "5", 37 | "name": "Mission Impossible", 38 | "poster" : "mission_impossible.jpeg", 39 | "rating" : 7.1, 40 | "link" : "http://www.imdb.com/title/tt0258463/" 41 | }, 42 | { 43 | "actors": "Arnold Schwarzenegger, Linda Hamilton", 44 | "id": "6", 45 | "name": "Terminator", 46 | "poster" : "terminator.jpeg", 47 | "rating" : 8.0, 48 | "link" : "http://www.imdb.com/title/tt0088247/" 49 | }, 50 | { 51 | "actors": "Leonardo DiCaprio, Kate Winslet", 52 | "id": "7", 53 | "name": "Titanic", 54 | "poster" : "titanic.jpeg", 55 | "rating" : 7.7, 56 | "link" : "http://www.imdb.com/title/tt0120338/" 57 | }, 58 | { 59 | "actors": "Robert Downey Jr, Gwyneth Paltrow, Terrence Howard", 60 | "id": "8", 61 | "name": "Iron Man", 62 | "poster" : "iron_man.jpeg", 63 | "rating" : 7.9, 64 | "link" : "http://www.imdb.com/title/tt0371746/" 65 | }, 66 | { 67 | "actors": "Brad Pitt, Diane Kruger", 68 | "id": "9", 69 | "name": "Inglorious Bastards", 70 | "poster" : "inglorious_basterds.jpeg", 71 | "rating" : 8.3, 72 | "link" : "http://www.imdb.com/title/tt0361748/" 73 | }, 74 | { 75 | "actors": "Hillary Swank, Client Eastwood", 76 | "id": "10", 77 | "name": "Million Dollar Baby", 78 | "poster" : "million_dollar_baby.jpeg", 79 | "rating" : 8.1, 80 | "link" : "http://www.imdb.com/title/tt0405159/" 81 | 82 | }, 83 | { 84 | "actors": "Uma Thurman", 85 | "id": "11", 86 | "name": "Kill Bill", 87 | "poster" : "kill_bill.jpeg", 88 | "rating" : 8.1, 89 | "link" : "http://www.imdb.com/title/tt0266697/" 90 | }, 91 | { 92 | "actors": "Jennifer Lawrence", 93 | "id": "12", 94 | "name": "The Hunger Games", 95 | "poster" : "the_hunger_games.jpeg", 96 | "rating" : 7.2, 97 | "link" : "http://www.imdb.com/title/tt1392170/" 98 | }, 99 | { 100 | "actors": "Bradley Cooper, Zach Galifianakis", 101 | "id": "13", 102 | "name": "The Hangover", 103 | "poster" : "the_hangover.jpeg", 104 | "rating" : 7.8, 105 | "link" : "http://www.imdb.com/title/tt1119646/" 106 | }, 107 | { 108 | "actors": "Tom Hanks, Michael Keaton", 109 | "id": "14", 110 | "name": "Toy Story", 111 | "poster" : "toy_story.jpeg", 112 | "rating" : 7.3, 113 | "link" : "http://www.imdb.com/title/tt0114709/" 114 | }, 115 | { 116 | "actors": "Daniel Radcliffe, Emma Watson", 117 | "id": "15", 118 | "name": "Harry Potter", 119 | "poster" : "harry_potter.jpeg", 120 | "rating" : 7.5, 121 | "link" : "http://www.imdb.com/title/tt0241527/" 122 | }, 123 | { 124 | "actors": "Sam Worthington, Sigourney Weaver", 125 | "id": "16", 126 | "name": "Avatar", 127 | "poster" : "avatar.jpeg", 128 | "rating" : 7.8, 129 | "link" : "http://www.imdb.com/title/tt0499549/" 130 | }, 131 | { 132 | "actors": "Anil Kapoor, Dev Patel, Freida Pinto", 133 | "id": "17", 134 | "name": "Slumdog Millionaire", 135 | "poster" : "slumdog_millionaire.jpeg", 136 | "rating" : 8.0, 137 | "link" : "http://www.imdb.com/title/tt1010048/" 138 | }, 139 | { 140 | "actors": "Brad Pitt, Cate Blanchett", 141 | "id": "18", 142 | "name": "The Curious Case of Benjamin Button", 143 | "poster" : "the_curious_case_of_benjamin_button.jpeg", 144 | "rating" : 7.8, 145 | "link" : "http://www.imdb.com/title/tt0421715/" 146 | }, 147 | { 148 | "actors": "Matt Damon, Julia Stiles", 149 | "id": "19", 150 | "name": "The Bourne Ultimatum", 151 | "poster" : "the_bourne_ultimatum.jpeg", 152 | "rating" : 8.1, 153 | "link" : "http://www.imdb.com/title/tt0440963/" 154 | }, 155 | { 156 | "actors": "Steve Martin, Kevin Kline", 157 | "id": "20", 158 | "name": "The Pink Panther", 159 | "poster" : "the_pink_panther.jpeg", 160 | "rating" : 7.2, 161 | "link" : "http://www.imdb.com/title/tt0057413/" 162 | } 163 | ]; 164 | 165 | export default movies; 166 | 167 | -------------------------------------------------------------------------------- /react-client/src/data/sales.csv: -------------------------------------------------------------------------------- 1 | 1,500.00 2 | 2,660.00 3 | 3,80.00 4 | 4,470.00 5 | 5,1100.x0 6 | 6,240.00 7 | 7,1000.00 8 | 8,2300.00 9 | 9,230.00 10 | 10,600.00 11 | 11,800.00 12 | 12,1400.00 13 | 13,780.00 14 | 14,890.00 15 | 15,490.00 16 | 16,670.00 17 | 17,450.x0 18 | 18,1230.00 19 | 19,700.00 20 | 20,900.00 -------------------------------------------------------------------------------- /react-client/src/routes.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { Route, IndexRoute } from 'react-router' 3 | import Layout from './components/Layout'; 4 | import IndexPage from './components/IndexPage'; 5 | import MoviePage from './components/MoviePage'; 6 | import NotFoundPage from './components/NotFoundPage'; 7 | 8 | 9 | const routes = ( 10 | 11 | 12 | 13 | 14 | 15 | ); 16 | 17 | export default routes; 18 | 19 | -------------------------------------------------------------------------------- /react-client/src/static/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/.DS_Store -------------------------------------------------------------------------------- /react-client/src/static/css/style.css: -------------------------------------------------------------------------------- 1 | /*! CSS reset from benfrain/app-reset */ 2 | *,:after,:before{box-sizing:inherit}html{box-sizing:border-box} 3 | *{user-select:none;-webkit-tap-highlight-color:rgba(255,255,255,0);-webkit-tap-highlight-color:transparent} 4 | [contenteditable],input[type]{user-select:text}body,h1,h2,h3,h4,h5,h6,p{margin:0;font-size:1rem;font-weight:400} 5 | a{text-decoration:none;color:inherit}b{font-weight:400}em,i{font-style:normal}a:focus,input:focus{outline:0} 6 | fieldset,input{appearance:none;border:0;padding:0;margin:0;min-width:0;font-size:1rem;font-family:inherit} 7 | input::-ms-clear{display:none}input[type=number]{-moz-appearance:textfield} 8 | input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{appearance:none} 9 | svg{display:inline-flex}img{max-width:100%;display:block} 10 | 11 | html { 12 | color: #030303; 13 | font: caption; 14 | padding-bottom: 2em; 15 | } 16 | 17 | a { 18 | color: #1f4ba0; 19 | text-decoration: underline; 20 | } 21 | 22 | header { 23 | padding: 2em; 24 | } 25 | 26 | .container { 27 | display: block; 28 | margin: 0 auto; 29 | max-height: 50%; 30 | /*max-width: 550px;*/ 31 | width: 100%; 32 | /* position: relative; */ 33 | text-align: center; 34 | color: white; 35 | } 36 | 37 | .container img { 38 | max-height:100%; 39 | max-width: 100%; 40 | } 41 | 42 | .centered { 43 | position: absolute; 44 | top: 15%; 45 | left: 35%; 46 | transform: translate(-50%, -50%); 47 | font-family: 'Ubuntu', sans-serif; 48 | font-size: 8em; 49 | font-weight: 700; 50 | font-style: italic; 51 | color: #9408C4; 52 | } 53 | 54 | header .group { 55 | position: absolute; 56 | width: 100%; 57 | bottom: 0; 58 | margin: 0 auto; 59 | text-align: center; 60 | } 61 | 62 | footer { 63 | margin: 4em auto; 64 | padding: 2em; 65 | text-align: center; 66 | max-width: 800px; 67 | width: 100%; 68 | } 69 | 70 | footer p { 71 | line-height: 1.2em; 72 | margin: 0 0 1em 0; 73 | } 74 | 75 | .not-found { 76 | margin: 0 auto; 77 | max-width: 800px; 78 | padding: 2em; 79 | text-align: center; 80 | width: 100%; 81 | } 82 | 83 | .not-found h1 { 84 | font-size: 3em; 85 | font-weight: bold; 86 | } 87 | 88 | .not-found h2 { 89 | font-size: 2em; 90 | font-weight: bold; 91 | } 92 | 93 | .home .movies-selector { 94 | clear: both; 95 | padding: 2em; 96 | text-align: center; 97 | } 98 | 99 | .home .movies-selector .movie-preview { 100 | border: 1px solid #ccc; 101 | box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12); 102 | display: inline-block; 103 | margin: 0 1em 1em 0; 104 | max-width: 200px; 105 | padding: 0; 106 | position: relative; 107 | width: 100%; 108 | } 109 | 110 | .home .movies-selector .movie-preview img { 111 | margin: 0; 112 | width: 100%; 113 | } 114 | 115 | .home .movies-selector .movie-preview .name { 116 | color: #030303; 117 | display: inline-block; 118 | font-size: 1.6em; 119 | overflow: hidden; 120 | padding: .2em; 121 | text-align: center; 122 | text-decoration: none; 123 | text-overflow: ellipsis; 124 | white-space: nowrap; 125 | width: 100%; 126 | } 127 | 128 | .home .movies-selector .movie-preview .medals-count { 129 | background: #fff; 130 | border-radius: 2px; 131 | display: inline-block; 132 | font-weight: bold; 133 | margin: .2em; 134 | padding: .2em .4em; 135 | position: absolute; 136 | right: 0; 137 | text-align: center; 138 | top: 0; 139 | vertical-align: middle; 140 | } 141 | 142 | nav.movies-menu { 143 | margin: 0 auto; 144 | max-width: 800px; 145 | padding: 2em; 146 | text-align: center; 147 | width: 100%; 148 | } 149 | 150 | nav.movies-menu a { 151 | font-size: 1.6em; 152 | margin: 0 1em 1em 0; 153 | } 154 | 155 | nav.movies-menu a.active { 156 | color: #030303; 157 | text-decoration: none; 158 | } 159 | 160 | .movie { 161 | border: 1px solid #ccc; 162 | box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12); 163 | margin: 0 auto; 164 | max-width: 800px; 165 | width: 100%; 166 | } 167 | 168 | .movie header { 169 | background: #ccc; 170 | background-position: center center; 171 | background-repeat: no-repeat; 172 | background-size: cover; 173 | width: 100%; 174 | height: 200px; 175 | } 176 | 177 | .movie .picture-container { 178 | margin: -160px 0 0 0; 179 | padding: 0 1em 0 1em; 180 | } 181 | 182 | .container { 183 | margin: -160px 0 0 0; 184 | padding: 0 1em 0 1em; 185 | } 186 | 187 | .movie .picture-container img { 188 | border-radius: 4px; 189 | /* border: 8px solid #fff; */ 190 | box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12); 191 | display: inline; 192 | margin: 0 0 0 1em; 193 | width: 200px; 194 | max-height: 350px; 195 | } 196 | 197 | .movie .picture-container h2 { 198 | display: inline; 199 | font-size: 3em; 200 | padding: 0 0 0 .5em; 201 | width: auto; 202 | } 203 | 204 | .movie .flag .icon { 205 | display: inline-block; 206 | padding-bottom: .1em; 207 | width: auto; 208 | } 209 | 210 | .movie .description { 211 | font-size: 1.6em; 212 | padding: 1em; 213 | } 214 | 215 | .navigateBack { 216 | font-size: 1.6em; 217 | padding: 2em; 218 | text-align: center; 219 | text-decoration: none; 220 | } 221 | 222 | #abar { 223 | bottom: 0; 224 | left: 0; 225 | position: fixed; 226 | width: 100%; 227 | } 228 | 229 | #abar a { 230 | background: #ffa500; 231 | color: #000; 232 | display: block; 233 | font-weight: bold; 234 | margin: 0; 235 | padding: 1em; 236 | text-align: center; 237 | text-decoration: none; 238 | width: 100%; 239 | } 240 | 241 | #abar a:hover { 242 | text-decoration: underline; 243 | } 244 | -------------------------------------------------------------------------------- /react-client/src/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/favicon.ico -------------------------------------------------------------------------------- /react-client/src/static/img/BulkResizePhotos.com.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /react-client/src/static/img/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/avatar.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/banner.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/harry_potter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/harry_potter.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/inception.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/inception.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/inglorious_basterds.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/inglorious_basterds.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/iron_man.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/iron_man.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/kill_bill.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/kill_bill.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/million_dollar_baby.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/million_dollar_baby.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/mission_impossible.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/mission_impossible.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/slumdog_millionaire.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/slumdog_millionaire.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/terminator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/terminator.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/the_bourne_ultimatum.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/the_bourne_ultimatum.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/the_curious_case_of_benjamin_button.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/the_curious_case_of_benjamin_button.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/the_hangover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/the_hangover.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/the_hunger_games.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/the_hunger_games.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/the_lord_of_the_rings.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/the_lord_of_the_rings.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/the_matrix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/the_matrix.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/the_pink_panther.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/the_pink_panther.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/the_shining.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/the_shining.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/titanic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/titanic.jpg -------------------------------------------------------------------------------- /react-client/src/static/img/toy_story.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dockersamples/javaee-demo/0acff8f51d2be3642ee65b2ae16b29546272c19b/react-client/src/static/img/toy_story.jpg -------------------------------------------------------------------------------- /react-client/src/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Movieplex 7 - MTA 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /react-client/webpack.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const path = require('path'); 3 | 4 | module.exports = { 5 | entry: path.join(__dirname, 'src', 'app-client.js'), 6 | output: { 7 | path: path.join(__dirname, 'src', 'static', 'js'), 8 | filename: 'bundle.js' 9 | }, 10 | module: { 11 | rules: [{ 12 | // test: path.join(__dirname, 'src'), 13 | test: /\.jsx?$/, 14 | use: 15 | { 16 | loader: 'babel-loader', 17 | options: { 18 | cacheDirectory: 'babel_cache', 19 | presets: ['react', 'es2015'] 20 | } 21 | } 22 | }] 23 | }, 24 | plugins: [ 25 | new webpack.DefinePlugin({ 26 | 'process.env' : { 27 | NODE_ENV: JSON.stringify(process.env.NODE_ENV), 28 | API_HOST: JSON.stringify(process.env.API_HOST || "localhost:8080") 29 | } 30 | }) 31 | ] 32 | }; 33 | --------------------------------------------------------------------------------