[jboss-cvs] jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay ...
Shane Bryzak
sbryzak at redhat.com
Sun Apr 15 23:57:49 EDT 2007
User: sbryzak2
Date: 07/04/15 23:57:49
Modified: examples/seambay/src/org/jboss/seam/example/seambay
Auction.java AuctionAction.java
AuctionSearchAction.java AuctionService.java
AuctionServiceRemote.java Authenticator.java
User.java
Added: examples/seambay/src/org/jboss/seam/example/seambay
Account.java
Log:
separated user login details
Revision Changes Path
1.7 +6 -6 jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/Auction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Auction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/Auction.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- Auction.java 16 Apr 2007 01:40:08 -0000 1.6
+++ Auction.java 16 Apr 2007 03:57:49 -0000 1.7
@@ -23,7 +23,7 @@
private static final long serialVersionUID = -8349473227099432431L;
private Integer auctionId;
- private User user;
+ private Account account;
private Category category;
private String title;
private String description;
@@ -46,15 +46,15 @@
}
@ManyToOne
- @JoinColumn(name = "USER_ID")
- public User getUser()
+ @JoinColumn(name = "ACCOUNT_ID")
+ public Account getAccount()
{
- return user;
+ return account;
}
- public void setUser(User user)
+ public void setAccount(Account account)
{
- this.user = user;
+ this.account = account;
}
@ManyToOne
1.3 +4 -10 jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/AuctionAction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AuctionAction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/AuctionAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- AuctionAction.java 11 Apr 2007 15:41:04 -0000 1.2
+++ AuctionAction.java 16 Apr 2007 03:57:49 -0000 1.3
@@ -1,9 +1,9 @@
package org.jboss.seam.example.seambay;
import static org.jboss.seam.ScopeType.CONVERSATION;
+
import java.io.Serializable;
import java.util.Calendar;
-import java.util.Date;
import java.util.GregorianCalendar;
import javax.persistence.EntityManager;
@@ -24,7 +24,7 @@
@In EntityManager entityManager;
- @In User authenticatedUser;
+ @In Account authenticatedAccount;
private Auction auction;
@@ -34,14 +34,8 @@
public void createAuction()
{
auction = new Auction();
- auction.setUser(authenticatedUser);
-
- //auction.setStatus(Auction.STATUS_UNLISTED);
-
- // temporary
- auction.setStatus(Auction.STATUS_LIVE);
- auction.setEndDate(new Date(System.currentTimeMillis() + (1000 * 60 * 60 * 24 * 7)));
-
+ auction.setAccount(authenticatedAccount);
+ auction.setStatus(Auction.STATUS_UNLISTED);
entityManager.persist(auction);
}
1.7 +11 -6 jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/AuctionSearchAction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AuctionSearchAction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/AuctionSearchAction.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- AuctionSearchAction.java 16 Apr 2007 01:40:08 -0000 1.6
+++ AuctionSearchAction.java 16 Apr 2007 03:57:49 -0000 1.7
@@ -16,6 +16,8 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.datamodel.DataModel;
+import org.jboss.seam.annotations.datamodel.DataModelSelection;
@Name("auctionSearch")
@Scope(ScopeType.SESSION)
@@ -32,8 +34,12 @@
private String searchTerm;
private Category searchCategory;
+ @DataModel
private List<Auction> auctions;
+ @DataModelSelection
+ private Auction selectedAuction;
+
private Map<Category,Long> searchCategories = new HashMap<Category,Long>();
@SuppressWarnings("unchecked")
@@ -85,7 +91,6 @@
}
@Factory
-
public String getSearchTerm()
{
return searchTerm;
@@ -116,11 +121,6 @@
this.page = page;
}
- public List<Auction> getResults()
- {
- return auctions;
- }
-
public List<Entry> getSearchCategories()
{
List<Entry> cats = new ArrayList<Entry>(searchCategories.entrySet());
@@ -145,6 +145,11 @@
return searchCategory;
}
+ public List<Auction> getAuctions()
+ {
+ return auctions;
+ }
+
public void setSearchCategory(Category category)
{
this.searchCategory = category;
1.8 +14 -5 jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/AuctionService.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AuctionService.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/AuctionService.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- AuctionService.java 16 Apr 2007 01:40:08 -0000 1.7
+++ AuctionService.java 16 Apr 2007 03:57:49 -0000 1.8
@@ -51,6 +51,18 @@
}
@WebMethod
+ public Auction getNewAuctionDetails(int auctionId)
+ {
+ AuctionAction action = (AuctionAction) Component.getInstance(AuctionAction.class, true);
+
+ action.editAuction(auctionId);
+
+ // TODO remove the auction image from the result
+
+ return action.getAuction();
+ }
+
+ @WebMethod
public void updateAuction(int auctionId, String title, String description, int categoryId)
{
AuctionAction action = (AuctionAction) Component.getInstance(AuctionAction.class, true);
@@ -85,9 +97,6 @@
search.setSearchTerm(searchTerm);
search.queryAuctions();
- // TODO - trim the result somehow, or use DTOs. We don't want to send user records
- // (including their passwords!!) here, nor do we want to send a huge object graph.
-
- return search.getResults().toArray(new Auction[search.getResults().size()]);
+ return search.getAuctions().toArray(new Auction[search.getAuctions().size()]);
}
}
1.6 +1 -0 jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/AuctionServiceRemote.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AuctionServiceRemote.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/AuctionServiceRemote.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- AuctionServiceRemote.java 16 Apr 2007 01:40:08 -0000 1.5
+++ AuctionServiceRemote.java 16 Apr 2007 03:57:49 -0000 1.6
@@ -11,6 +11,7 @@
Category[] listCategories();
Integer createAuction(String title, String description, int categoryId);
+ Auction getNewAuctionDetails(int auctionId);
void updateAuction(int auctionId, String title, String description, int categoryId);
void setAuctionDuration(int auctionId, int days);
void confirmAuction(int auctionId);
1.3 +1 -0 jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/Authenticator.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Authenticator.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/Authenticator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Authenticator.java 11 Apr 2007 05:29:55 -0000 1.2
+++ Authenticator.java 16 Apr 2007 03:57:49 -0000 1.3
@@ -28,6 +28,7 @@
.getSingleResult();
Contexts.getSessionContext().set("authenticatedUser", user);
+ Contexts.getSessionContext().set("authenticatedAccount", user.getAccount());
return true;
}
1.3 +18 -0 jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/User.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: User.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/User.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- User.java 29 Mar 2007 13:54:59 -0000 1.2
+++ User.java 16 Apr 2007 03:57:49 -0000 1.3
@@ -5,6 +5,10 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+
+import org.hibernate.validator.NotNull;
@Entity
public class User implements Serializable
@@ -14,6 +18,7 @@
private Integer userId;
private String username;
private String password;
+ private Account account;
@Id @GeneratedValue
public Integer getUserId()
@@ -45,4 +50,17 @@
{
this.password = password;
}
+
+ @OneToOne
+ @NotNull
+ @JoinColumn(name = "ACCOUNT_ID")
+ public Account getAccount()
+ {
+ return account;
+ }
+
+ public void setAccount(Account account)
+ {
+ this.account = account;
+ }
}
1.1 date: 2007/04/16 03:57:49; author: sbryzak2; state: Exp;jboss-seam/examples/seambay/src/org/jboss/seam/example/seambay/Account.java
Index: Account.java
===================================================================
package org.jboss.seam.example.seambay;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Account implements Serializable
{
private static final long serialVersionUID = 8444287111124328025L;
private Integer accountId;
private String name;
private int feedbackCount;
private float feedbackScore;
private Date memberSince;
@Id @GeneratedValue
public Integer getAccountId()
{
return accountId;
}
public void setAccountId(Integer accountId)
{
this.accountId = accountId;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getFeedbackCount()
{
return feedbackCount;
}
public void setFeedbackCount(int count)
{
this.feedbackCount = count;
}
public float getFeedbackScore()
{
return feedbackScore;
}
public void setFeedbackScore(float score)
{
this.feedbackScore = score;
}
public Date getMemberSince()
{
return memberSince;
}
public void setMemberSince(Date memberSince)
{
this.memberSince = memberSince;
}
}
More information about the jboss-cvs-commits
mailing list