openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r774537 [1/3] - in /incubator/openwebbeans/trunk/samples/reservation: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/webbeans/ src/main/java/org/apache/webbeans/reservation/ src/main/j...
Date Wed, 13 May 2009 21:09:49 GMT
Author: gerdogdu
Date: Wed May 13 21:09:47 2009
New Revision: 774537

URL: http://svn.apache.org/viewvc?rev=774537&view=rev
Log:
Importing reservation sample

Added:
    incubator/openwebbeans/trunk/samples/reservation/pom.xml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/
    incubator/openwebbeans/trunk/samples/reservation/src/main/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LoginBean.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LogoutBean.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminBean.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListBean.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListUser.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserListBean.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserUpdateBean.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/ApplicationLog.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/DatabaseLogin.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/intercep/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/intercep/Transactional.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/LoginController.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/RegisterController.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/admin/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/admin/AdminController.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/ILoginController.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/IRegisterController.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/user/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/user/UserController.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/entity/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/entity/Hotel.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/entity/Reservation.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/entity/User.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/events/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/events/LoggedInEvent.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/LoginDecorator.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/model/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/model/ReservationModel.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/security/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/security/JSFSecurityPhaseListener.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/session/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/session/SessionTracker.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/CalendarUtil.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/JSFUtility.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/LogUtil.java   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/resources/
    incubator/openwebbeans/trunk/samples/reservation/src/main/resources/META-INF/
    incubator/openwebbeans/trunk/samples/reservation/src/main/resources/META-INF/beans.xml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/resources/META-INF/persistence.xml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/resources/log4j.properties   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/META-INF/
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/META-INF/MANIFEST.MF   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/WEB-INF/
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/WEB-INF/beans.xml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/WEB-INF/faces-config.xml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/WEB-INF/lib/
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/WEB-INF/web.xml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/admin/
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/admin/defineHotel.xhtml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/admin/listHotels.xhtml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/admin/listUsers.xhtml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/admin/menu.xhtml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/index.html   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/login.xhtml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/main.css   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/register.xhtml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/user/
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/user/addReservation.xhtml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/user/listReservations.xhtml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/user/menu.xhtml   (with props)
    incubator/openwebbeans/trunk/samples/reservation/src/main/webapp/user/updateInfo.xhtml   (with props)

Added: incubator/openwebbeans/trunk/samples/reservation/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/pom.xml?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/pom.xml (added)
+++ incubator/openwebbeans/trunk/samples/reservation/pom.xml Wed May 13 21:09:47 2009
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	
+	Licensed to the Apache Software Foundation (ASF) under one or more
+	contributor license agreements. See the NOTICE file distributed with
+	this work for additional information regarding copyright ownership.
+	The ASF licenses this file to You under the Apache License, Version
+	2.0 (the "License"); you may not use this file except in compliance
+	with the License. You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+	applicable law or agreed to in writing, software distributed under the
+	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+	CONDITIONS OF ANY KIND, either express or implied. See the License for
+	the specific language governing permissions and limitations under the
+	License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+	     <artifactId>samples</artifactId>
+	     <groupId>org.apache.openwebbeans</groupId>
+	     <version>1.0.0-incubating-SNAPSHOT</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.apache.openwebbeans.samples</groupId>
+	<artifactId>reservation</artifactId>
+	<packaging>war</packaging>
+	<name>OpenWebBeans :: Sample Hotel Reservation Application</name>
+	<description>Simple hotel reservation application</description>
+
+	<build>
+		<finalName>reservation</finalName>
+	</build>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.facelets</groupId>
+            <artifactId>jsf-facelets</artifactId>
+            <version>1.1.11</version>
+        </dependency>
+
+        <dependency>
+                <groupId>org.apache.geronimo.specs</groupId>
+                <artifactId>geronimo-el_1.0_spec</artifactId>
+                <version>1.0-M1</version>
+                <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-api</artifactId>
+            <version>1.0.0-incubating-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-jsf</artifactId>
+            <version>1.0.0-incubating-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-jpa</artifactId>
+            <version>1.0.0-incubating-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.myfaces.core</groupId>
+            <artifactId>myfaces-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+        	<groupId>commons-validator</groupId>
+        	<artifactId>commons-validator</artifactId>
+        	<version>1.3.1</version>
+        </dependency>
+	
+      </dependencies>
+
+    <properties>
+        <envlibscope>provided</envlibscope>
+    </properties>
+    
+	<profiles>
+		<profile>
+			<id>jetty</id>
+                        <dependencies>
+            
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-api</artifactId>
+                    <version>1.0.0-incubating-SNAPSHOT</version>
+                    <scope>compile</scope> <!-- we need this if we run in jetty! -->
+                </dependency>
+            
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-impl</artifactId>
+                    <version>1.0.0-incubating-SNAPSHOT</version>
+                </dependency>
+            
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-jsf</artifactId>
+                    <version>1.0.0-incubating-SNAPSHOT</version>
+                </dependency>
+            
+                <dependency>
+                    <groupId>org.apache.openwebbeans</groupId>
+                    <artifactId>openwebbeans-jpa</artifactId>
+                    <version>1.0.0-incubating-SNAPSHOT</version>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.openjpa</groupId>
+                    <artifactId>openjpa</artifactId>
+                    <version>1.2.0</version>
+                </dependency>
+            
+                <dependency>
+                    <groupId>hsqldb</groupId>
+                    <artifactId>hsqldb</artifactId>
+                    <version>1.8.0.7</version>
+                </dependency>
+            
+                <dependency>
+                    <groupId>org.apache.myfaces.core</groupId>
+                    <artifactId>myfaces-api</artifactId>
+                    <scope>compile</scope> <!-- we need this if we run in jetty! -->
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.myfaces.core</groupId>
+                    <artifactId>myfaces-impl</artifactId>
+                </dependency>
+            </dependencies>
+
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.mortbay.jetty</groupId>
+                        <artifactId>maven-jetty-plugin</artifactId>
+                        <version>6.1.15.rc4</version>
+                        <configuration>
+                            <scanIntervalSeconds>10</scanIntervalSeconds>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+
+            <pluginRepositories>
+                <!-- Repository to get the jetty plugin -->
+                <pluginRepository>
+                     <id>mortbay-repo</id>
+                     <name>mortbay-repo</name>
+                     <url>http://www.mortbay.org/maven2/snapshot</url>
+                </pluginRepository>
+            </pluginRepositories>
+
+            <properties>
+                <envlibscope>compile</envlibscope>
+            </properties>
+	
+	</profile>
+     </profiles>
+
+</project>

Propchange: incubator/openwebbeans/trunk/samples/reservation/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LoginBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LoginBean.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LoginBean.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LoginBean.java Wed May 13 21:09:47 2009
@@ -0,0 +1,133 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.beans;
+
+import java.lang.annotation.Annotation;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.event.Event;
+import javax.event.Fires;
+
+import org.apache.commons.validator.GenericValidator;
+import org.apache.webbeans.reservation.bindings.DatabaseLogin;
+import org.apache.webbeans.reservation.controller.LoginController;
+import org.apache.webbeans.reservation.entity.User;
+import org.apache.webbeans.reservation.events.LoggedInEvent;
+import org.apache.webbeans.reservation.util.JSFUtility;
+
+/**
+ * Contains login related managed bean functionality.
+ */
+@RequestScoped
+@Named
+public class LoginBean
+{
+    /**User name*/
+    private String userName;
+    
+    /**Password*/
+    private String password;
+
+    /**Inject of the event instance*/
+    private @Fires Event<LoggedInEvent> loggedInEvent;
+    
+    /**Database related login controller*/
+    private @DatabaseLogin LoginController loginController;
+
+    /**
+     * Check user login.
+     * 
+     * @return navigation result
+     */
+    public String login()
+    {
+        if(GenericValidator.isBlankOrNull(userName) || GenericValidator.isBlankOrNull(password))
+        {
+            JSFUtility.addErrorMessage("User name and password fields can not be empty", "");
+            
+            return null;
+        }
+        
+        User result = loginController.checkLogin(userName, password);
+        
+        if(result == null)
+        {
+            JSFUtility.addErrorMessage("Login failed!,User name or password is not correct. Try again!", "");
+            
+            return null;
+        }
+        
+        User user = result;
+        
+        //Fire Event
+        LoggedInEvent event = new LoggedInEvent(user);
+        loggedInEvent.fire(event, new Annotation[0]);
+        
+        
+        if(user.isAdmin())
+        {
+            return "adminHome";
+        }
+        
+        return "userHome";
+    }
+    
+    /**
+     * Check user logout.
+     * 
+     * @return navigation result
+     */
+    public String logout()
+    {
+        return null;
+    }
+
+    /**
+     * @return the userName
+     */
+    public String getUserName()
+    {
+        return userName;
+    }
+
+    /**
+     * @param userName the userName to set
+     */
+    public void setUserName(String userName)
+    {
+        this.userName = userName;
+    }
+
+    /**
+     * @return the password
+     */
+    public String getPassword()
+    {
+        return password;
+    }
+
+    /**
+     * @param password the password to set
+     */
+    public void setPassword(String password)
+    {
+        this.password = password;
+    }
+    
+    
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LoginBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LogoutBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LogoutBean.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LogoutBean.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LogoutBean.java Wed May 13 21:09:47 2009
@@ -0,0 +1,49 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.beans;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.servlet.http.HttpSession;
+
+import org.apache.webbeans.reservation.util.JSFUtility;
+
+@RequestScoped
+@Named
+public class LogoutBean
+{ 
+    
+    /**
+     * Logs out from the system.
+     * 
+     * @return navigate output
+     */
+    public String logout()
+    {
+        HttpSession session =  JSFUtility.getCurrentSession();
+        
+        if(session != null)
+        {
+            session.invalidate();
+        }
+        
+        JSFUtility.addInfoMessage("You have successfully logged out!", "");
+        
+        return "login";
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/LogoutBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java Wed May 13 21:09:47 2009
@@ -0,0 +1,174 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.beans;
+
+import javax.annotation.Named;
+import javax.annotation.PostConstruct;
+import javax.context.RequestScoped;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+
+import org.apache.commons.logging.Log;
+import org.apache.webbeans.reservation.bindings.ApplicationLog;
+import org.apache.webbeans.reservation.controller.RegisterController;
+import org.apache.webbeans.reservation.util.JSFUtility;
+
+@Named(value="register")
+@RequestScoped
+public class RegisterBean
+{
+    private @ApplicationLog Log logger;
+    
+    private String name;
+    
+    private String surname;
+    
+    private Integer age;
+    
+    private String userName;
+    
+    private String password;
+    
+    private boolean admin;
+    
+    private @Current RegisterController personController;
+    
+    private @Current Manager manager; 
+    
+    public RegisterBean()
+    {
+        
+    }
+    
+    public String register()
+    {   
+        
+        logger.info("Registering the new user with user name : " + userName);
+        
+        personController.registerUser(userName, password, name, surname, age, admin);
+        
+        JSFUtility.addInfoMessage("User with name : " + userName + " is registered successfully.", "");
+        
+        return "login";
+
+    }
+
+    @PostConstruct
+    public void init()
+    {
+        logger = (Log)manager.getInstanceByName("logger");
+    }
+    
+    
+    /**
+     * @return the name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * @return the surname
+     */
+    public String getSurname()
+    {
+        return surname;
+    }
+
+    /**
+     * @param surname the surname to set
+     */
+    public void setSurname(String surname)
+    {
+        this.surname = surname;
+    }
+
+    /**
+     * @return the age
+     */
+    public Integer getAge()
+    {
+        return age;
+    }
+
+    /**
+     * @param age the age to set
+     */
+    public void setAge(Integer age)
+    {
+        this.age = age;
+    }
+
+    /**
+     * @return the userName
+     */
+    public String getUserName()
+    {
+        return userName;
+    }
+
+    /**
+     * @param userName the userName to set
+     */
+    public void setUserName(String userName)
+    {
+        this.userName = userName;
+    }
+
+    /**
+     * @return the password
+     */
+    public String getPassword()
+    {
+        return password;
+    }
+
+    /**
+     * @param password the password to set
+     */
+    public void setPassword(String password)
+    {
+        this.password = password;
+    }
+
+    /**
+     * @return the admin
+     */
+    public boolean isAdmin()
+    {
+        return admin;
+    }
+
+    /**
+     * @param admin the admin to set
+     */
+    public void setAdmin(boolean admin)
+    {
+        this.admin = admin;
+    }
+    
+    
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/RegisterBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminBean.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminBean.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminBean.java Wed May 13 21:09:47 2009
@@ -0,0 +1,129 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.beans.admin;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.inject.Current;
+
+import org.apache.webbeans.reservation.controller.admin.AdminController;
+import org.apache.webbeans.reservation.util.JSFUtility;
+
+/**
+ * Admin JSF Bean.
+ */
+@RequestScoped
+@Named
+public class AdminBean
+{
+    private String name;
+    
+    private String city;
+    
+    private String country;
+    
+    private Number star;
+    
+    private @Current AdminController adminController;
+
+    /**
+     * Add new hotel
+     * 
+     * @return navigation case
+     */
+    public String addNewHotel()
+    {
+        adminController.createNewHotel(name, star.intValue(), city, country);
+        
+        JSFUtility.addInfoMessage("Hotel  '" + name +  "' is successfully created", "");
+        
+        setCity(null);
+        setCountry(null);
+        setName(null);
+        setStar(null);
+        
+        
+        return null;
+        
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * @return the city
+     */
+    public String getCity()
+    {
+        return city;
+    }
+
+    /**
+     * @param city the city to set
+     */
+    public void setCity(String city)
+    {
+        this.city = city;
+    }
+
+    /**
+     * @return the country
+     */
+    public String getCountry()
+    {
+        return country;
+    }
+
+    /**
+     * @param country the country to set
+     */
+    public void setCountry(String country)
+    {
+        this.country = country;
+    }
+
+    /**
+     * @return the star
+     */
+    public Number getStar()
+    {
+        return star;
+    }
+
+    /**
+     * @param star the star to set
+     */
+    public void setStar(Number star)
+    {
+        this.star = star;
+    }
+    
+    
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListBean.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListBean.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListBean.java Wed May 13 21:09:47 2009
@@ -0,0 +1,172 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.beans.admin;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+import javax.faces.component.html.HtmlDataTable;
+import javax.inject.Current;
+
+import org.apache.webbeans.reservation.controller.admin.AdminController;
+import org.apache.webbeans.reservation.entity.Hotel;
+import org.apache.webbeans.reservation.util.JSFUtility;
+
+@Named
+@SessionScoped
+public class AdminListBean implements Serializable
+{
+
+    private static final long serialVersionUID = 2552807646330035889L;
+
+    private List<Hotel> hotels = new ArrayList<Hotel>();
+    
+    private HtmlDataTable model;
+    
+    private @Current AdminController controller;
+    
+    private Hotel selected;
+    
+    private boolean renderedDetailPanel = false;
+    
+    
+    public String update()
+    {
+        if(selected == null)
+        {
+            JSFUtility.addErrorMessage("Pleasee select the hotel to update", "");
+            
+            return null;
+        }
+        
+        controller.updateHotel(selected.getId(), selected.getName(), selected.getStar(), selected.getCity(), selected.getCountry());
+        
+        JSFUtility.addInfoMessage("Hotel with name " + selected.getName()+ " is succesfully updated." , "");
+        
+        
+        return null;
+    }
+    
+    public String delete()
+    {
+        selected = (Hotel)model.getRowData();
+        
+        if(selected == null)
+        {
+            JSFUtility.addErrorMessage("Pleasee select the hotel to delete", "");
+            
+            return null;
+        }
+     
+        controller.deleteHotel(selected.getId());
+        
+        JSFUtility.addInfoMessage("Hotel with name " + selected.getName()+ " is succesfully deleted." , "");
+        
+        this.selected.setCity(null);
+        this.selected.setCountry(null);
+        this.selected.setName(null);
+        this.selected.setStar(0);
+        
+        
+        
+        return null;
+    }
+    
+    public String getForUpdate()
+    {
+        Hotel hotel = (Hotel) model.getRowData();
+        
+        this.selected = hotel;
+        
+        setRenderedDetailPanel(true);
+        
+                
+        return null;
+    }
+    
+    /**
+     * @return the hotels
+     */
+    public List<Hotel> getHotels()
+    {
+        hotels = controller.getHotels();
+        
+        return hotels;
+    }
+
+    /**
+     * @param hotels the hotels to set
+     */
+    public void setHotels(List<Hotel> hotels)
+    {
+        this.hotels = hotels;
+    }
+
+    /**
+     * @return the model
+     */
+    public HtmlDataTable getModel()
+    {
+        return model;
+    }
+
+    /**
+     * @param model the model to set
+     */
+    public void setModel(HtmlDataTable model)
+    {
+        this.model = model;
+    }
+
+    /**
+     * @return the selected
+     */
+    public Hotel getSelected()
+    {
+        return selected;
+    }
+
+    /**
+     * @param selected the selected to set
+     */
+    public void setSelected(Hotel selected)
+    {
+        this.selected = selected;
+    }
+
+    /**
+     * @return the renderedDetailPanel
+     */
+    public boolean isRenderedDetailPanel()
+    {
+        return renderedDetailPanel;
+    }
+
+    /**
+     * @param renderedDetailPanel the renderedDetailPanel to set
+     */
+    public void setRenderedDetailPanel(boolean renderedDetailPanel)
+    {
+        this.renderedDetailPanel = renderedDetailPanel;
+    }
+    
+    
+    
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListUser.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListUser.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListUser.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListUser.java Wed May 13 21:09:47 2009
@@ -0,0 +1,117 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.beans.admin;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.Named;
+
+import javax.context.RequestScoped;
+import javax.faces.component.html.HtmlDataTable;
+import javax.inject.Current;
+
+import org.apache.webbeans.reservation.controller.admin.AdminController;
+import org.apache.webbeans.reservation.entity.Hotel;
+import org.apache.webbeans.reservation.entity.User;
+
+@Named
+@RequestScoped
+public class AdminListUser
+{
+    private List<User> users = new ArrayList<User>();
+    
+    private @Current AdminController controller;
+    
+    private HtmlDataTable model;
+    
+    private List<Hotel> hotels = new ArrayList<Hotel>();
+    
+    public AdminListUser()
+    {
+        
+    }
+
+    public String getReservations()
+    {
+        User user = (User) model.getRowData();
+        
+        Set<Hotel> set  = this.controller.getReservationsWithUser(user.getId());
+        for(Hotel hotel : set)
+        {
+            hotels.add(hotel);
+        }
+        
+        return null;
+    }
+    
+    /**
+     * @return the users
+     */
+    public List<User> getUsers()
+    {   
+        this.users = this.controller.getUsers(); 
+        
+        return this.users; 
+    }
+
+    /**
+     * @param users the users to set
+     */
+    public void setUsers(List<User> users)
+    {
+        this.users = users;
+    }
+
+    /**
+     * @return the model
+     */
+    public HtmlDataTable getModel()
+    {
+        return model;
+    }
+
+    /**
+     * @param model the model to set
+     */
+    public void setModel(HtmlDataTable model)
+    {
+        this.model = model;
+    }
+
+    /**
+     * @return the hotels
+     */
+    public List<Hotel> getHotels()
+    {
+        
+       return hotels;
+
+    }
+
+    /**
+     * @param hotels the hotels to set
+     */
+    public void setHotels(List<Hotel> hotels)
+    {
+        this.hotels = hotels;
+    }
+
+    
+    
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/admin/AdminListUser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserListBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserListBean.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserListBean.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserListBean.java Wed May 13 21:09:47 2009
@@ -0,0 +1,102 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.beans.user;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.faces.component.html.HtmlDataTable;
+import javax.inject.Current;
+
+import org.apache.webbeans.reservation.controller.user.UserController;
+import org.apache.webbeans.reservation.entity.Reservation;
+import org.apache.webbeans.reservation.session.SessionTracker;
+import org.apache.webbeans.reservation.util.JSFUtility;
+
+@Named("listReservationBean")
+@RequestScoped
+public class UserListBean
+{
+
+    private List<Reservation> reservations = new ArrayList<Reservation>();
+    
+    private HtmlDataTable model = null;
+    
+    private @Current UserController controller;
+    
+    private @Current SessionTracker tracker;
+    
+    public UserListBean()
+    {
+        
+    }
+
+    public String delete()
+    {
+        Reservation res = (Reservation)model.getRowData();
+        
+        controller.deleteReservation(res.getId());
+        
+        JSFUtility.addInfoMessage("Reservation is succesfully delete", "");
+        
+        
+        return null;
+    }
+    
+    public String showReservations()
+    {
+        return "toReservePage";
+    }
+    
+    /**
+     * @return the reservations
+     */
+    public List<Reservation> getReservations()
+    {
+        this.reservations = this.controller.getReservations(tracker.getUser().getId());
+        
+        return reservations;
+    }
+
+    /**
+     * @param reservations the reservations to set
+     */
+    public void setReservations(List<Reservation> reservations)
+    {
+        this.reservations = reservations;
+    }
+
+    /**
+     * @return the model
+     */
+    public HtmlDataTable getModel()
+    {
+        return model;
+    }
+
+    /**
+     * @param model the model to set
+     */
+    public void setModel(HtmlDataTable model)
+    {
+        this.model = model;
+    }
+    
+    
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserListBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java Wed May 13 21:09:47 2009
@@ -0,0 +1,291 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.beans.user;
+
+import java.io.Serializable;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
+import javax.faces.component.html.HtmlDataTable;
+import javax.faces.model.SelectItem;
+import javax.inject.Current;
+
+import org.apache.webbeans.reservation.controller.admin.AdminController;
+import org.apache.webbeans.reservation.controller.user.UserController;
+import org.apache.webbeans.reservation.entity.Hotel;
+import org.apache.webbeans.reservation.model.ReservationModel;
+import org.apache.webbeans.reservation.session.SessionTracker;
+import org.apache.webbeans.reservation.util.JSFUtility;
+
+@Named
+@ConversationScoped
+public class UserReservationBean implements Serializable
+{
+    private static final long serialVersionUID = -5860989760497059459L;
+
+    private List<SelectItem> reservations = new ArrayList<SelectItem>();
+    
+    private @Current UserController controller;
+    
+    private List<Hotel> hotels = new ArrayList<Hotel>();
+    
+    private @Current AdminController adminController;
+    
+    private String reservationDate;
+    
+    private HtmlDataTable model;
+    
+    private @Current Conversation conversation;
+    
+    private @Current SessionTracker tracker;
+        
+    private Integer[] itemSelected = new Integer[0];
+    
+    private Map<String, ReservationModel> models = new HashMap<String, ReservationModel>();
+    
+    public UserReservationBean()
+    {
+    }
+
+    
+    public String addReservation()
+    {
+        if(getReservationDate() == null)
+        {
+            JSFUtility.addErrorMessage("Reservation date can not be empty!", "");
+            return null;
+        }
+             
+        Date date = null;
+        try
+        {
+            date = new SimpleDateFormat("dd/MM/yyyy").parse(getReservationDate());
+            
+        }catch(Exception e){
+            
+            JSFUtility.addErrorMessage("Please give a date with dd/MM/yyyy", "");
+            return null;
+        }
+        
+        if(!conversation.isLongRunning())
+        {
+            conversation.begin();
+            
+            JSFUtility.addInfoMessage("Reservation conversation with started with id : " + conversation.getId(), "");            
+        }
+        
+        Hotel hotel = (Hotel)model.getRowData();
+        
+        SelectItem item = new SelectItem();
+        item.setValue(hotel.getId());
+        item.setLabel(hotel.getName());
+        
+        if(contains(item.getValue()) != null)
+        {
+            JSFUtility.addErrorMessage("Given hotel is already added", "");
+            
+            return null;
+        }
+                
+        reservations.add(item);
+        
+        
+        ReservationModel model = new ReservationModel(item,date);
+        models.put(item.getValue().toString(), model);
+        
+        return null;
+    }
+    
+    private SelectItem contains(Object id)
+    {
+        for(SelectItem i : reservations)
+        {
+            if(i.getValue().toString().equals(id.toString()))
+            {
+                return i;
+            }
+        }
+        
+        return null;
+        
+    }
+    
+    public String delete()
+    {
+        if(this.itemSelected.length == 0)
+        {
+            JSFUtility.addErrorMessage("Please select reservation to remove", "");
+            
+            return null;
+        }
+        
+        for(Integer i : this.itemSelected)
+        {
+            SelectItem item = null;
+            if((item = contains(i)) != null)
+            {
+                this.reservations.remove(item);   
+                
+                this.models.remove(item);
+            }    
+        }
+        
+        
+        return null;
+    }
+    
+    public String checkout()
+    {
+        if(!conversation.isLongRunning())
+        {
+            JSFUtility.addErrorMessage("Conversation is not running! Please add hotel for reservation", "");
+            this.reservations.clear();
+            this.reservationDate = null;
+        }
+        else
+        {
+            this.controller.addReservation(models,tracker.getUser().getId());
+            
+            conversation.end();
+            
+            JSFUtility.addInfoMessage("Reservation are completed succesfully. Conversation with id "+conversation.getId() + " is ended ", "");
+            
+            this.reservations.clear();
+            
+            this.reservationDate = null;            
+        }        
+        
+        return null;
+    }
+
+
+    /**
+     * @return the reservations
+     */
+    public List<SelectItem> getReservations()
+    {
+        return reservations;
+    }
+
+    
+    public String clear()
+    {
+        this.reservations.clear();
+                
+        this.reservationDate = null;
+        
+        if(conversation.isLongRunning())
+        {
+            this.conversation.end();
+            JSFUtility.addInfoMessage("Reservation are deleted succesfully. Conversation with id "+conversation.getId() + "is ended ", "");
+        }
+        
+        return null;
+    }
+
+    /**
+     * @param reservations the reservations to set
+     */
+    public void setReservations(List<SelectItem> reservations)
+    {
+        this.reservations = reservations;
+    }
+
+
+    /**
+     * @return the hotels
+     */
+    public List<Hotel> getHotels()
+    {
+        this.hotels = this.adminController.getHotels();
+        
+        return hotels;
+    }
+
+
+    /**
+     * @param hotels the hotels to set
+     */
+    public void setHotels(List<Hotel> hotels)
+    {
+        this.hotels = hotels;
+    }
+
+
+    /**
+     * @return the reservationDate
+     */
+    public String getReservationDate()
+    {
+        return reservationDate;
+    }
+
+
+    /**
+     * @param reservationDate the reservationDate to set
+     */
+    public void setReservationDate(String reservationDate)
+    {
+        this.reservationDate = reservationDate;
+    }
+
+
+    /**
+     * @return the model
+     */
+    public HtmlDataTable getModel()
+    {
+        return model;
+    }
+
+
+    /**
+     * @param model the model to set
+     */
+    public void setModel(HtmlDataTable model)
+    {
+        this.model = model;
+    }
+
+
+    /**
+     * @return the itemSelected
+     */
+    public Integer[] getItemSelected()
+    {
+        
+        return itemSelected;
+    }
+
+
+    /**
+     * @param itemSelected the itemSelected to set
+     */
+    public void setItemSelected(Integer[] itemSelected)
+    {
+        this.itemSelected = itemSelected;
+    }
+    
+    
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserReservationBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserUpdateBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserUpdateBean.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserUpdateBean.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserUpdateBean.java Wed May 13 21:09:47 2009
@@ -0,0 +1,166 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.beans.user;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.inject.Current;
+
+import org.apache.webbeans.reservation.controller.user.UserController;
+import org.apache.webbeans.reservation.entity.User;
+import org.apache.webbeans.reservation.session.SessionTracker;
+import org.apache.webbeans.reservation.util.JSFUtility;
+
+@Named
+@RequestScoped
+public class UserUpdateBean
+{
+    private String name;
+    
+    private String surname;
+    
+    private int age;
+    
+    private String userName;
+    
+    private String password;
+    
+    private @Current UserController controller;
+    
+    private @Current SessionTracker tracker;
+    
+    public UserUpdateBean()
+    {
+        
+    }
+
+    public String showInfo()
+    {
+        //Just show how can access session webbeans
+        User user = this.controller.getUser(tracker.getUser().getId());
+        
+        setName(user.getName());
+        setSurname(user.getSurname());
+        setAge(user.getAge());
+        setUserName(user.getUserName());
+        setPassword(user.getPassword());
+                
+        return "toUpdatePage";
+    }
+
+    public String clear()
+    {
+        setName("");
+        setSurname("");
+        setAge(0);
+        setUserName("");
+        setPassword("");
+        
+        return null;
+    }
+    
+    public String update()
+    {
+        this.controller.updateUserInfo(tracker.getUser().getId(), name, surname, age, userName, password);
+        
+        JSFUtility.addInfoMessage("Personal information is succesfully updated.", "");
+        
+        return null;
+    }
+    
+    /**
+     * @return the name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * @return the surname
+     */
+    public String getSurname()
+    {
+        return surname;
+    }
+
+    /**
+     * @param surname the surname to set
+     */
+    public void setSurname(String surname)
+    {
+        this.surname = surname;
+    }
+
+    /**
+     * @return the age
+     */
+    public int getAge()
+    {
+        return age;
+    }
+
+    /**
+     * @param age the age to set
+     */
+    public void setAge(int age)
+    {
+        this.age = age;
+    }
+
+    /**
+     * @return the userName
+     */
+    public String getUserName()
+    {
+        return userName;
+    }
+
+    /**
+     * @param userName the userName to set
+     */
+    public void setUserName(String userName)
+    {
+        this.userName = userName;
+    }
+
+    /**
+     * @return the password
+     */
+    public String getPassword()
+    {
+        return password;
+    }
+
+    /**
+     * @param password the password to set
+     */
+    public void setPassword(String password)
+    {
+        this.password = password;
+    }
+    
+    
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/beans/user/UserUpdateBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/ApplicationLog.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/ApplicationLog.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/ApplicationLog.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/ApplicationLog.java Wed May 13 21:09:47 2009
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.bindings;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.PARAMETER;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@BindingType
+@Retention(RetentionPolicy.RUNTIME)
+@Target( {FIELD, METHOD, TYPE,PARAMETER})
+public @interface ApplicationLog
+{
+
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/ApplicationLog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/DatabaseLogin.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/DatabaseLogin.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/DatabaseLogin.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/DatabaseLogin.java Wed May 13 21:09:47 2009
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.bindings;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.PARAMETER;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@BindingType
+@Retention(RetentionPolicy.RUNTIME)
+@Target( {FIELD, METHOD, TYPE,PARAMETER})
+public @interface DatabaseLogin
+{
+
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/DatabaseLogin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/intercep/Transactional.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/intercep/Transactional.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/intercep/Transactional.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/intercep/Transactional.java Wed May 13 21:09:47 2009
@@ -0,0 +1,32 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.bindings.intercep;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBindingType;
+
+@InterceptorBindingType
+@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.TYPE, ElementType.METHOD })
+public @interface Transactional
+{
+
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/bindings/intercep/Transactional.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/LoginController.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/LoginController.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/LoginController.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/LoginController.java Wed May 13 21:09:47 2009
@@ -0,0 +1,85 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.controller;
+
+import java.util.GregorianCalendar;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.inject.Current;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.commons.validator.GenericValidator;
+import org.apache.webbeans.reservation.bindings.DatabaseLogin;
+import org.apache.webbeans.reservation.bindings.intercep.Transactional;
+import org.apache.webbeans.reservation.controller.api.ILoginController;
+import org.apache.webbeans.reservation.entity.User;
+
+@DatabaseLogin
+@RequestScoped
+@Named
+public class LoginController implements ILoginController
+{
+    private Logger logger = Logger.getLogger(LoginController.class.getName());
+    
+    /**Injection of the request scope entity manager*/
+    private @Current EntityManager entityManager;
+
+    /**
+     * Returns true if user exist else false
+     * 
+     * @param userName user name
+     * @param password user password
+     * @return true if user exist else false
+     */
+    @Transactional
+    public User checkLogin(String userName, String password)
+    {
+        if(GenericValidator.isBlankOrNull(userName) || GenericValidator.isBlankOrNull(password))
+        {
+            logger.log(Level.WARNING, "UserName and Password is null");
+            
+            return null;
+        }
+        
+        Query query = entityManager.createQuery("select p from User p where  " +
+        		                                "p.userName=:userName and " +
+        		                                "p.password=:password");
+        
+        query.setParameter("userName", userName);
+        query.setParameter("password", password);
+        
+        User value = null;
+        try
+        {
+            value =(User)query.getSingleResult();
+            value.setLastLoginDate(GregorianCalendar.getInstance().getTime());
+        }
+        catch(Exception e)
+        {
+            return null;
+        }
+                
+        
+        return value;
+    }
+    
+
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/LoginController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/RegisterController.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/RegisterController.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/RegisterController.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/RegisterController.java Wed May 13 21:09:47 2009
@@ -0,0 +1,71 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.controller;
+
+import javax.context.RequestScoped;
+import javax.inject.Current;
+import javax.persistence.EntityManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.validator.GenericValidator;
+import org.apache.webbeans.reservation.bindings.ApplicationLog;
+import org.apache.webbeans.reservation.bindings.intercep.Transactional;
+import org.apache.webbeans.reservation.controller.api.IRegisterController;
+import org.apache.webbeans.reservation.entity.User;
+import org.apache.webbeans.reservation.util.CalendarUtil;
+
+/**
+ * Controller responsible for registering operations.
+ */
+@RequestScoped
+public class RegisterController implements IRegisterController
+{
+    private @ApplicationLog Log logger;
+    
+    private @Current EntityManager entityManager;
+
+    /**
+     * Register the user.
+     */
+    @Transactional
+    public User registerUser(String userName, String password, String name, String surname , int age, boolean admin)
+    {
+        logger.debug("Register a new user with user name : " + userName);
+        
+        if(GenericValidator.isBlankOrNull(userName) || GenericValidator.isBlankOrNull(password))
+        {
+            logger.debug("Registering is failed. User name and password can not be null");
+            return null;
+        }
+        
+        User user = new User();
+        
+        user.setUserName(userName);
+        user.setPassword(password);
+        user.setName(name);
+        user.setSurname(surname);
+        user.setAge(age);
+        user.setRegisterDate(CalendarUtil.getCurrentDate());
+        user.setAdmin(admin);
+        
+        entityManager.persist(user);
+        
+        
+        return user;
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/RegisterController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/admin/AdminController.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/admin/AdminController.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/admin/AdminController.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/admin/AdminController.java Wed May 13 21:09:47 2009
@@ -0,0 +1,162 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.controller.admin;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.inject.Current;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.validator.GenericValidator;
+import org.apache.webbeans.reservation.bindings.ApplicationLog;
+import org.apache.webbeans.reservation.bindings.intercep.Transactional;
+import org.apache.webbeans.reservation.entity.Hotel;
+import org.apache.webbeans.reservation.entity.Reservation;
+import org.apache.webbeans.reservation.entity.User;
+
+/**
+ * Contains admin related activities.
+ */
+@Named
+@RequestScoped
+public class AdminController
+{
+    private @ApplicationLog Log logger;
+    
+    private @Current EntityManager entityManager;
+    
+    @Transactional
+    public void createNewHotel(String name, int star, String city, String country)
+    {        
+        
+        if(GenericValidator.isBlankOrNull(name) ||
+                GenericValidator.isBlankOrNull(city) ||
+                GenericValidator.isBlankOrNull(country))
+        {
+            logger.debug("Some of the parameters are missing to define hotel.");
+            
+            return;
+        }
+        
+        Hotel hotel = new Hotel();
+        hotel.setCity(city);
+        hotel.setCountry(country);
+        hotel.setName(name);
+        hotel.setStar(star);
+        
+        entityManager.persist(hotel);
+        
+    }
+    
+    @SuppressWarnings("unchecked")
+    public List<Hotel> getHotels()
+    {
+        Query query = this.entityManager.createQuery("select h from Hotel h");
+        
+        return  (List<Hotel>)query.getResultList();
+    }
+    
+    @SuppressWarnings("unchecked")
+    public List<User> getUsers()
+    {
+        Query query = this.entityManager.createQuery("select u from User u");
+        
+        return  (List<User>)query.getResultList();
+        
+    }
+
+    /**
+     * Returns hotel with given id.
+     * 
+     * @param id hotel id
+     * @return hotel
+     */
+    public Hotel getHotelWithId(int id)
+    {
+        Hotel hotel = this.entityManager.find(Hotel.class, id);
+        
+        return hotel;
+    }
+    
+    @SuppressWarnings("unchecked")
+    public List<User> getReservationsWithHotel(int hotelId)
+    {
+        Query query = this.entityManager.createQuery("select u from User u join fetch u.reservations r where r.id=:id");
+        query.setParameter("id", hotelId);
+        
+        List<User> users = query.getResultList();
+        
+        return users;
+    }
+    
+    public Set<Hotel> getReservationsWithUser(int userId)
+    {
+        Query query = this.entityManager.createQuery("select u from User u where u.id=:id");
+        query.setParameter("id", userId);
+        
+        User user = (User)query.getSingleResult();
+        
+        Set<Hotel> hotels = new HashSet<Hotel>();
+        
+        Set<Reservation> reservations = user.getReservations();
+        
+        for(Reservation reserve : reservations)
+        {
+            hotels.add(reserve.getHotel());
+        }
+        
+        return hotels;
+    }
+    
+    
+    @Transactional
+    public void updateHotel(int id, String name, int star, String city, String country)
+    {
+        Hotel hotel = this.entityManager.find(Hotel.class, id);
+        
+        hotel.setName(name);
+        hotel.setStar(star);
+        hotel.setCountry(country);
+        hotel.setCity(city);
+    }
+    
+    @Transactional
+    @SuppressWarnings("unchecked")
+    public void deleteHotel(int id)
+    {
+        Hotel hotel = this.entityManager.find(Hotel.class, id);
+        
+        this.entityManager.remove(hotel);
+        
+        Query query = this.entityManager.createQuery("select r from Reservation r where r.hotel.id=:id");
+        query.setParameter("id",hotel.getId());
+        
+        List<Reservation> res = query.getResultList();
+        
+        for(Reservation r : res)
+        {
+            this.entityManager.remove(r);
+        }
+        
+    }
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/admin/AdminController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/ILoginController.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/ILoginController.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/ILoginController.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/ILoginController.java Wed May 13 21:09:47 2009
@@ -0,0 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.controller.api;
+
+
+import org.apache.webbeans.reservation.entity.User;
+
+public interface ILoginController
+{
+    public User checkLogin(String userName, String password);
+
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/ILoginController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/IRegisterController.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/IRegisterController.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/IRegisterController.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/IRegisterController.java Wed May 13 21:09:47 2009
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.controller.api;
+
+import org.apache.webbeans.reservation.entity.User;
+
+public interface IRegisterController
+{
+    public User registerUser(String userName, String password, String name, String surname , int age, boolean admin);
+
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/api/IRegisterController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/user/UserController.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/user/UserController.java?rev=774537&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/user/UserController.java (added)
+++ incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/user/UserController.java Wed May 13 21:09:47 2009
@@ -0,0 +1,135 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.webbeans.reservation.controller.user;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+import javax.faces.model.SelectItem;
+import javax.inject.Current;
+import javax.persistence.EntityManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.webbeans.reservation.bindings.ApplicationLog;
+import org.apache.webbeans.reservation.bindings.intercep.Transactional;
+import org.apache.webbeans.reservation.entity.Hotel;
+import org.apache.webbeans.reservation.entity.Reservation;
+import org.apache.webbeans.reservation.entity.User;
+import org.apache.webbeans.reservation.model.ReservationModel;
+
+@RequestScoped
+public class UserController
+{
+    private @Current EntityManager entityManager;
+    
+    private @ApplicationLog Log logger;
+
+    public UserController()
+    {
+        
+    }
+    
+    @PostConstruct
+    public void postConstruct()
+    {
+        System.out.println("Post Construct Sample .... " + UserController.class.getName() + " is instantiated");
+        
+    }
+    
+    @PreDestroy
+    public void preDestroy()
+    {
+        System.out.println("Pre Destroy Construct Sample .... " + UserController.class.getName() + " is destroyed by the container");
+    }
+    
+    public User getUser(int id)
+    {
+        User user = this.entityManager.find(User.class, id);
+        
+        return user;
+    }
+    
+    @Transactional
+    public void updateUserInfo(int userId, String name, String surname, int age, String userName, String password)
+    {
+        logger.debug("Updating user with id : " + userId);
+        
+        User user = this.entityManager.find(User.class, userId);
+        
+        user.setName(name);
+        user.setSurname(surname);
+        user.setAge(age);
+        user.setUserName(userName);
+        user.setPassword(password);
+    }
+    
+    @Transactional
+    public void addReservation(Map<String, ReservationModel> reservations, int userId)
+    {
+        User user = this.entityManager.find(User.class, userId);
+        
+        Set<String> keys = reservations.keySet();
+        
+        for(String item : keys)
+        {
+            ReservationModel rm = reservations.get(item);
+            SelectItem si = rm.getItem();
+            Hotel hotel = this.entityManager.find(Hotel.class, si.getValue());
+            
+            Reservation reservation = new Reservation();
+            
+            user.addHotel(reservation);
+            
+            reservation.setHotel(hotel);
+            reservation.setReservationDate(rm.getDate());
+            
+            this.entityManager.persist(reservation);            
+        }
+                
+    }
+    
+    @Transactional
+    public void deleteReservation(int reservsitonId)
+    {
+        Reservation res = this.entityManager.find(Reservation.class, reservsitonId);
+        User user = res.getUser();
+        
+        user.getReservations().remove(res);
+        
+        this.entityManager.remove(res);
+    }
+    
+    public List<Reservation> getReservations(int id)
+    {
+        User user = this.entityManager.find(User.class, id);
+        
+        Set<Reservation> res = user.getReservations();
+        
+        List<Reservation> l = new ArrayList<Reservation>();
+        for(Reservation r : res)
+        {
+            l.add(r);
+        }
+        
+        return l;
+    }
+}

Propchange: incubator/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/controller/user/UserController.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message