[seam-commits] Seam SVN: r11765 - in modules/remoting/trunk/examples/model: src/main/java/org/jboss/seam/remoting/examples/model and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sun Dec 6 18:49:03 EST 2009


Author: shane.bryzak at jboss.com
Date: 2009-12-06 18:49:03 -0500 (Sun, 06 Dec 2009)
New Revision: 11765

Added:
   modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/Customer.java
   modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java
Modified:
   modules/remoting/trunk/examples/model/pom.xml
Log:
example classes


Modified: modules/remoting/trunk/examples/model/pom.xml
===================================================================
--- modules/remoting/trunk/examples/model/pom.xml	2009-12-06 23:05:29 UTC (rev 11764)
+++ modules/remoting/trunk/examples/model/pom.xml	2009-12-06 23:49:03 UTC (rev 11765)
@@ -44,6 +44,15 @@
          <artifactId>seam-remoting</artifactId>
          <version>3.0.0-SNAPSHOT</version>
       </dependency>
+
+      <dependency>
+         <groupId>javax.persistence</groupId>
+         <artifactId>persistence-api</artifactId>
+         <version>1.0</version>
+         <scope>provided</scope>
+      </dependency>
+
+
       
    </dependencies>
    

Added: modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/Customer.java
===================================================================
--- modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/Customer.java	                        (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/Customer.java	2009-12-06 23:49:03 UTC (rev 11765)
@@ -0,0 +1,79 @@
+package org.jboss.seam.remoting.examples.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * Customer entity bean.  This class exposes a variety of property types for the
+ * purpose of the example.
+ *  
+ * @author Shane Bryzak
+ */
+ at Entity
+public class Customer implements Serializable
+{
+   private static final long serialVersionUID = 4289723352398788625L;
+
+   public enum Gender { male, female }
+   
+   private Integer customerId;
+   private String firstName;
+   private String lastName;
+   private Date dateOfBirth;
+   private Gender gender;
+   
+   @Id @GeneratedValue
+   public Integer getCustomerId()
+   {
+      return customerId;
+   }
+   
+   public void setCustomerId(Integer customerId)
+   {
+      this.customerId = customerId;
+   }
+   
+   public String getFirstName()
+   {
+      return firstName;
+   }
+   
+   public void setFirstName(String firstName)
+   {
+      this.firstName = firstName;
+   }
+   
+   public String getLastName()
+   {
+      return lastName;
+   }
+   
+   public void setLastName(String lastName)
+   {
+      this.lastName = lastName;
+   }
+   
+   public Date getDateOfBirth()
+   {
+      return dateOfBirth;
+   }
+   
+   public void setDateOfBirth(Date dateOfBirth)
+   {
+      this.dateOfBirth = dateOfBirth;
+   }
+   
+   public Gender getGender()
+   {
+      return gender;
+   }
+   
+   public void setGender(Gender gender)
+   {
+      this.gender = gender;
+   }
+}

Added: modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java
===================================================================
--- modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java	                        (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java	2009-12-06 23:49:03 UTC (rev 11765)
@@ -0,0 +1,49 @@
+package org.jboss.seam.remoting.examples.model;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+ at ConversationScoped
+public class CustomerAction implements Serializable
+{
+   private static final long serialVersionUID = 8350706339578435242L;
+   
+   @Inject EntityManager entityManager;
+   @Inject Conversation conversation;
+   
+   private Customer customer;
+      
+   public void createCustomer()
+   {
+      conversation.begin();
+      customer = new Customer();
+   }
+   
+   public void editCustomer(Integer customerId)
+   {
+      conversation.begin();
+      customer = entityManager.find(Customer.class, customerId);
+   }
+   
+   public void saveCustomer()
+   {
+      if (customer.getCustomerId() == null)
+      {
+         entityManager.persist(customer);
+      }
+      else
+      {
+         customer = entityManager.merge(customer);
+      }
+      conversation.end();
+   }
+   
+   public Customer getCustomer()
+   {
+      return customer;
+   }
+}



More information about the seam-commits mailing list