[weld-commits] Weld SVN: r6442 - in examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode: session and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Jun 16 09:43:02 EDT 2010


Author: pete.muir at jboss.org
Date: 2010-06-16 09:43:01 -0400 (Wed, 16 Jun 2010)
New Revision: 6442

Added:
   examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/EEProducers.java
Removed:
   examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeEntity.java
Modified:
   examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeFragment.java
Log:
merge in shane's changes

Deleted: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeEntity.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeEntity.java	2010-06-16 13:35:18 UTC (rev 6441)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeEntity.java	2010-06-16 13:43:01 UTC (rev 6442)
@@ -1,208 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.weld.examples.pastecode.model;
-
-import java.io.Serializable;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.GenerationType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Column;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Lob;
-import javax.persistence.Transient;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * The persistent class for the code database table.
- * 
- */
- at Entity
- at Table(name = "code")
-public class CodeEntity implements Serializable, Cloneable
-{
-   private static final long MS_PER_SECOND = 1000;
-   private static final long MS_PER_MINUTE = 60 * MS_PER_SECOND;
-   private static final long MS_PER_HOUR = 60 * MS_PER_MINUTE;
-   private static final long MS_PER_DAY = 24 * MS_PER_HOUR;
-   
-   private static final SimpleDateFormat df = new SimpleDateFormat("d MMM");   
-   
-   private static final long serialVersionUID = 1L;
-   private int id;
-   private Date datetime;
-   private String language;
-   private String note;
-   private String text;
-   private String user;
-   private String hash;
-
-   @Id
-   @GeneratedValue(strategy = GenerationType.IDENTITY)
-   @Column(name = "id")
-   public int getId()
-   {
-      return id;
-   }
-
-   public void setId(int id)
-   {
-      this.id = id;
-   }
-
-   @Column(name = "hash")
-   public String getHash()
-   {
-      return hash;
-   }
-
-   public void setHash(String hash)
-   {
-      this.hash = hash;
-   }
-
-   public CodeEntity()
-   {
-      this.language = "";
-      this.note = "";
-      this.text = "";
-      this.user = "";
-      this.hash = null;
-      this.datetime = null;
-   }
- 
-   @Temporal(TemporalType.TIMESTAMP)
-   @Column(name = "datetime")
-   public Date getDatetime()
-   {
-      return this.datetime;
-   }
-
-   public void setDatetime(Date datetime)
-   {
-      this.datetime = datetime;
-   }
-   
-   @Transient
-   public String getFriendlyDate()
-   {
-      if (getDatetime() == null) return "unknown";
-      
-      Date now = new Date();
-      
-      long age = now.getTime() - getDatetime().getTime();
-      
-      long days = (long) Math.floor(age / MS_PER_DAY);
-      age -= (days * MS_PER_DAY);
-      long hours = (long) Math.floor(age / MS_PER_HOUR);
-      age -= (hours * MS_PER_HOUR);
-      long minutes = (long) Math.floor(age / MS_PER_MINUTE);
-      
-      if (days < 7)
-      {
-         StringBuilder sb = new StringBuilder();
-         
-         if (days > 0)
-         {
-            sb.append(days);
-            sb.append(days > 1 ? " days " : " day ");
-         }
-         
-         if (hours > 0)
-         {
-            sb.append(hours);
-            sb.append(hours > 1 ? " hrs " : " hr ");
-         }
-         
-         if (minutes > 0)
-         {
-            sb.append(minutes);
-            sb.append(minutes > 1 ? " minutes " : " minute ");
-         }
-         
-         if (hours == 0 && minutes == 0)
-         {
-            sb.append("just now");
-         }
-         else
-         {         
-            sb.append("ago");
-         }
-         
-         return sb.toString();
-      }
-      else
-      {
-         return df.format(getDatetime());
-      }      
-   }   
-
-   @Column(name = "language")
-   public String getLanguage()
-   {
-      return this.language;
-   }
-
-   public void setLanguage(String language)
-   {
-      this.language = language;
-   }
-
-   @Lob()
-   @Column(name = "note")
-   public String getNote()
-   {
-      return this.note;
-   }
-
-   public void setNote(String note)
-   {
-      this.note = note;
-   }
-
-   @Lob()
-   @Column(name = "text")
-   public String getText()
-   {
-      return this.text;
-   }
-
-   public void setText(String text)
-   {
-      this.text = text;
-   }
-
-   @Column(name = "user")
-   public String getUser()
-   {
-      return this.user;
-   }
-
-   public void setUser(String user)
-   {
-      this.user = user;
-   }
-}
\ No newline at end of file

Modified: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeFragment.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeFragment.java	2010-06-16 13:35:18 UTC (rev 6441)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeFragment.java	2010-06-16 13:43:01 UTC (rev 6442)
@@ -23,6 +23,7 @@
 
 import static javax.persistence.GenerationType.AUTO;
 
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 
@@ -46,6 +47,13 @@
 public class CodeFragment
 {
 
+   private static final long MS_PER_SECOND = 1000;
+   private static final long MS_PER_MINUTE = 60 * MS_PER_SECOND;
+   private static final long MS_PER_HOUR = 60 * MS_PER_MINUTE;
+   private static final long MS_PER_DAY = 24 * MS_PER_HOUR;
+
+   private static final SimpleDateFormat df = new SimpleDateFormat("d MMM");
+
    @Id
    @GeneratedValue(strategy = AUTO)
    @Column(name = "id")
@@ -107,6 +115,60 @@
       this.datetime = datetime;
    }
 
+   public String getFriendlyDate()
+   {
+      if (getDatetime() == null)
+         return "unknown";
+
+      Date now = new Date();
+
+      long age = now.getTime() - getDatetime().getTime();
+
+      long days = (long) Math.floor(age / MS_PER_DAY);
+      age -= (days * MS_PER_DAY);
+      long hours = (long) Math.floor(age / MS_PER_HOUR);
+      age -= (hours * MS_PER_HOUR);
+      long minutes = (long) Math.floor(age / MS_PER_MINUTE);
+
+      if (days < 7)
+      {
+         StringBuilder sb = new StringBuilder();
+
+         if (days > 0)
+         {
+            sb.append(days);
+            sb.append(days > 1 ? " days " : " day ");
+         }
+
+         if (hours > 0)
+         {
+            sb.append(hours);
+            sb.append(hours > 1 ? " hrs " : " hr ");
+         }
+
+         if (minutes > 0)
+         {
+            sb.append(minutes);
+            sb.append(minutes > 1 ? " minutes " : " minute ");
+         }
+
+         if (hours == 0 && minutes == 0)
+         {
+            sb.append("just now");
+         }
+         else
+         {
+            sb.append("ago");
+         }
+
+         return sb.toString();
+      }
+      else
+      {
+         return df.format(getDatetime());
+      }
+   }
+
    public Language getLanguage()
    {
       return language;

Added: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/EEProducers.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/EEProducers.java	                        (rev 0)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/EEProducers.java	2010-06-16 13:43:01 UTC (rev 6442)
@@ -0,0 +1,15 @@
+package org.jboss.weld.examples.pastecode.session;
+
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+public class EEProducers
+{
+   
+   @SuppressWarnings("unused")
+   @PersistenceContext(unitName = "pastecodeDatabase")
+   @Produces
+   private EntityManager em;
+   
+}


Property changes on: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/EEProducers.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native



More information about the weld-commits mailing list