Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break up into several modules: core library, jsf and gwt ui
- Loading branch information
Showing
305 changed files
with
6,986 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<name>TicketMonster::Core-Lib</name> | ||
<groupId>org.jboss.seam.examples</groupId> | ||
<artifactId>ticketmonster-core</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<!-- Parent --> | ||
<parent> | ||
<groupId>org.jboss.seam.examples</groupId> | ||
<artifactId>ticket-monster</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
|
||
<dependencies> | ||
|
||
|
||
</dependencies> | ||
|
||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
37 changes: 37 additions & 0 deletions
37
core/src/main/java/org/jboss/seam/example/ticketmonster/action/CategorySearch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.jboss.seam.example.ticketmonster.action; | ||
|
||
import java.util.List; | ||
|
||
import javax.enterprise.inject.Model; | ||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
|
||
import org.jboss.seam.example.ticketmonster.model.EventCategory; | ||
|
||
/** | ||
* Event Category search actions | ||
* | ||
* @author Shane Bryzak | ||
* | ||
*/ | ||
public @Model class CategorySearch | ||
{ | ||
@Inject EntityManager entityManager; | ||
|
||
private List<EventCategory> categories; | ||
|
||
private void loadCategories() | ||
{ | ||
categories = entityManager.createQuery("select c from EventCategory c").getResultList(); | ||
} | ||
|
||
public List<EventCategory> getCategories() | ||
{ | ||
if (categories == null) | ||
{ | ||
loadCategories(); | ||
} | ||
return categories; | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
core/src/main/java/org/jboss/seam/example/ticketmonster/action/DocumentResourceSearch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.jboss.seam.example.ticketmonster.action; | ||
|
||
import java.util.List; | ||
|
||
import javax.enterprise.inject.Model; | ||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
import javax.persistence.NoResultException; | ||
|
||
import org.jboss.seam.example.ticketmonster.model.DocumentResource; | ||
|
||
/** | ||
* Used to locate document resources. | ||
* | ||
* @author Shane Bryzak | ||
* | ||
*/ | ||
public @Model class DocumentResourceSearch | ||
{ | ||
@Inject EntityManager entityManager; | ||
|
||
public DocumentResource findResourceByKey(Long docId, String key) | ||
{ | ||
try | ||
{ | ||
return (DocumentResource) entityManager.createQuery( | ||
"select r from DocumentResource r where r.id = :id and r.key = :key") | ||
.setParameter("id", docId) | ||
.setParameter("key", key) | ||
.getSingleResult(); | ||
} | ||
catch (NoResultException ex) | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
core/src/main/java/org/jboss/seam/example/ticketmonster/action/EventAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package org.jboss.seam.example.ticketmonster.action; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
import javax.enterprise.context.Conversation; | ||
import javax.enterprise.context.ConversationScoped; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.persistence.EntityManager; | ||
|
||
import org.jboss.seam.example.ticketmonster.model.Document; | ||
import org.jboss.seam.example.ticketmonster.model.Event; | ||
import org.jboss.seam.example.ticketmonster.model.Revision; | ||
import org.jboss.seam.persistence.transaction.Transactional; | ||
import org.jboss.seam.servlet.http.HttpParam; | ||
|
||
/** | ||
* Event management related operations | ||
* | ||
* @author Shane Bryzak | ||
* | ||
*/ | ||
public @Named @ConversationScoped class EventAction implements Serializable | ||
{ | ||
private static final long serialVersionUID = 1735221845795268934L; | ||
|
||
@Inject EntityManager entityManager; | ||
@Inject Conversation conversation; | ||
@Inject @HttpParam("eventId") String eventId; | ||
|
||
private Event event; | ||
private String description; | ||
|
||
public void createEvent() | ||
{ | ||
conversation.begin(); | ||
event = new Event(); | ||
} | ||
|
||
public boolean isLoadEvent() | ||
{ | ||
if (event == null && eventId != null && conversation.isTransient()) | ||
{ | ||
conversation.begin(); | ||
event = entityManager.find(Event.class, Long.valueOf(eventId)); | ||
description = event.getDescription().getActiveRevision().getContent(); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
@Transactional | ||
public String save() | ||
{ | ||
if (event.getId() != null) | ||
{ | ||
entityManager.merge(event); | ||
|
||
if (!description.equals(event.getDescription().getActiveRevision().getContent())) | ||
{ | ||
Revision rev = new Revision(); | ||
rev.setContent(description); | ||
rev.setDocument(event.getDescription()); | ||
rev.setCreated(new Date()); | ||
|
||
entityManager.persist(rev); | ||
event.getDescription().setActiveRevision(rev); | ||
entityManager.merge(event.getDescription()); | ||
} | ||
} | ||
else | ||
{ | ||
Document doc = new Document(); | ||
event.setDescription(doc); | ||
|
||
if (description != null) | ||
{ | ||
Revision rev = new Revision(); | ||
rev.setContent(description); | ||
rev.setDocument(event.getDescription()); | ||
doc.setActiveRevision(rev); | ||
entityManager.persist(doc); | ||
entityManager.persist(rev); | ||
} | ||
else | ||
{ | ||
entityManager.persist(doc); | ||
} | ||
|
||
entityManager.persist(event); | ||
|
||
} | ||
|
||
conversation.end(); | ||
return "success"; | ||
} | ||
|
||
public String cancel() | ||
{ | ||
conversation.end(); | ||
return "cancel"; | ||
} | ||
|
||
public Event getEvent() | ||
{ | ||
return event; | ||
} | ||
|
||
public String getDescription() | ||
{ | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) | ||
{ | ||
this.description = description; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
core/src/main/java/org/jboss/seam/example/ticketmonster/action/EventDetail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.jboss.seam.example.ticketmonster.action; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.enterprise.inject.Model; | ||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
|
||
import org.jboss.seam.example.ticketmonster.model.Event; | ||
import org.jboss.seam.example.ticketmonster.model.Show; | ||
import org.jboss.seam.example.ticketmonster.model.Venue; | ||
import org.jboss.seam.remoting.annotations.WebRemote; | ||
import org.jboss.seam.servlet.http.HttpParam; | ||
|
||
/** | ||
* Provides data for the event booking screen. | ||
* | ||
* @author Shane Bryzak | ||
* | ||
*/ | ||
public @Model class EventDetail | ||
{ | ||
@Inject EntityManager entityManager; | ||
@Inject @HttpParam("eventId") String eventId; | ||
|
||
private Event event; | ||
private List<Venue> venues; | ||
|
||
private void loadEvent() | ||
{ | ||
Long id = eventId != null ? Long.valueOf(eventId) : null; | ||
event = entityManager.find(Event.class, id); | ||
} | ||
|
||
public Event getEvent() | ||
{ | ||
if (event == null) loadEvent(); | ||
return event; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public List<Venue> getVenues() | ||
{ | ||
if (venues == null) | ||
{ | ||
venues = new ArrayList<Venue>(); | ||
|
||
for (Show show : (List<Show>) entityManager.createQuery( | ||
"select s from Show s where s.event = :event") | ||
.setParameter("event", event) | ||
.getResultList()) | ||
{ | ||
if (!venues.contains(show.getVenue())) venues.add(show.getVenue()); | ||
} | ||
} | ||
|
||
return venues; | ||
} | ||
|
||
@WebRemote | ||
@SuppressWarnings("unchecked") | ||
public List<Show> getShows(Long eventId, Long venueId) | ||
{ | ||
return entityManager.createQuery( | ||
"select s from Show s where s.event.id = :eventId and s.venue.id = :venueId") | ||
.setParameter("eventId", eventId) | ||
.setParameter("venueId", venueId) | ||
.getResultList(); | ||
} | ||
|
||
|
||
} |
61 changes: 61 additions & 0 deletions
61
core/src/main/java/org/jboss/seam/example/ticketmonster/action/EventSearch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.jboss.seam.example.ticketmonster.action; | ||
|
||
import java.util.List; | ||
|
||
import javax.enterprise.inject.Model; | ||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
|
||
import org.jboss.seam.example.ticketmonster.model.Event; | ||
import org.jboss.seam.example.ticketmonster.model.EventCategory; | ||
import org.jboss.seam.servlet.http.HttpParam; | ||
|
||
/** | ||
* Event search actions handled here | ||
* | ||
* @author Shane Bryzak | ||
* | ||
*/ | ||
public @Model class EventSearch | ||
{ | ||
@Inject EntityManager entityManager; | ||
@Inject @HttpParam("category") String category; | ||
|
||
private List<Event> events; | ||
|
||
@SuppressWarnings("unchecked") | ||
private void loadEvents() | ||
{ | ||
events = (category != null) ? | ||
(List<Event>) entityManager.createQuery( | ||
"select e from Event e where e.category = :category") | ||
.setParameter("category", lookupCategory(Long.valueOf(category))) | ||
.getResultList() : | ||
(List<Event>) entityManager.createQuery( | ||
"select e from Event e where e.major = true") | ||
.getResultList(); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private void loadAllEvents() | ||
{ | ||
events = (List<Event>) entityManager.createQuery("select e from Event e").getResultList(); | ||
} | ||
|
||
public EventCategory lookupCategory(Long categoryId) | ||
{ | ||
return entityManager.find(EventCategory.class, categoryId); | ||
} | ||
|
||
public List<Event> getEvents() | ||
{ | ||
if (events == null) loadEvents(); | ||
return events; | ||
} | ||
|
||
public List<Event> getAllEvents() | ||
{ | ||
if (events == null) loadAllEvents(); | ||
return events; | ||
} | ||
} |
Oops, something went wrong.