Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Clarke2013-01-15 11:02:03 -0500
committerDoug Clarke2013-01-15 11:02:03 -0500
commit3662b722cabe9b8d609ff66f96b6c4737714a04b (patch)
treed6058d9c00606bdfce65848b3a05e87bc98a0022
parentd61b6bdffb53c915a47dbf3aed8b943885b1a505 (diff)
downloadmysports-3662b722cabe9b8d609ff66f96b6c4737714a04b.tar.gz
mysports-3662b722cabe9b8d609ff66f96b6c4737714a04b.tar.xz
mysports-3662b722cabe9b8d609ff66f96b6c4737714a04b.zip
Modified pom.xml for cross platform usage. Tests now running on MAC
-rw-r--r--admin.services/pom.xml2
-rw-r--r--admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java216
-rw-r--r--admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepository.java2
-rw-r--r--admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepositoryBean.java10
-rw-r--r--admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/AdminPersistenceTesting.java125
-rw-r--r--admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateDatabase.java6
-rw-r--r--admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateLeagues.java2
-rw-r--r--admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestHostedLeagueRepository.java6
-rw-r--r--admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/extensions/TestCreateOrmXml.java1
-rw-r--r--admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/HostedLeaguesService.java123
-rw-r--r--application/.classpath1
-rw-r--r--application/.settings/org.eclipse.jpt.core.prefs3
-rw-r--r--application/pom.xml8
-rw-r--r--application/src/main/webapp/WEB-INF/faces-config.xml2
-rw-r--r--application/src/main/webapp/leagues-template.jsf1
15 files changed, 283 insertions, 225 deletions
diff --git a/admin.services/pom.xml b/admin.services/pom.xml
index a1fe35c..580007d 100644
--- a/admin.services/pom.xml
+++ b/admin.services/pom.xml
@@ -97,7 +97,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
- <argLine>-javaagent:${user.home}\\.m2\\repository\\eclipselink\\example\\mysports\\persistence\\${project.version}\\persistence-${project.version}.jar</argLine>
+ <argLine>-javaagent:${user.home}/.m2/repository/eclipselink/example/mysports/persistence/${project.version}/persistence-${project.version}.jar</argLine>
<excludedGroups>eclipselink.example.mysports.admin.services.test.services.ServerTests</excludedGroups>
</configuration>
</plugin>
diff --git a/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java b/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java
index 0eaf26c..214d3e2 100644
--- a/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java
+++ b/admin.services/src/main/java/eclipselink/example/mysports/admin/examples/ExampleLeagueDefinition.java
@@ -32,104 +32,122 @@ import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
*/
public abstract class ExampleLeagueDefinition {
- private HostedLeague league;
-
- public ExampleLeagueDefinition(String id, String name, String scheme, String logoUrl, String dataSource) {
- this.league = new HostedLeague(id, name, scheme);
- this.league.setLogoUrl(logoUrl);
- this.league.setDatasourceName(dataSource);
- addExtensions();
- }
-
- public HostedLeague getLeague() {
- return league;
- }
-
- protected abstract void addExtensions();
-
- public static ExampleLeagueDefinition OSL = new ExampleLeagueDefinition("OSL", "Ottawa Soccer League", "black", "/logos/osl.png", "jdbc/MySports") {
- @Override
- protected void addExtensions() {
- getLeague().addPlayerExtension("allergies", "java.lang.String", "FLEX_1");
- }
- };
-
- public static ExampleLeagueDefinition HTHL = new ExampleLeagueDefinition("HTHL", "High Tech Hockey League", "red", "/logos/hthl.png", "jdbc/MySports") {
- @Override
- protected void addExtensions() {
- getLeague().addPlayerExtension("position", "java.lang.String", "FLEX_1");
- getLeague().addPlayerExtension("penaltyMinutes", "java.lang.Integer", "FLEX_2");
- }
- };
-
- public static ExampleLeagueDefinition KFL = new ExampleLeagueDefinition("KFL", "Kid's Football League", "green", "/logos/kfl.png", "jdbc/MySports") {
- @Override
- protected void addExtensions() {
- getLeague().addPlayerExtension("position", "java.lang.String", "FLEX_1");
- }
- };
-
- public static ExampleLeagueDefinition MHL = new ExampleLeagueDefinition("MHL", "Minor Hockey League", "red", "/logos/mhl.png", "jdbc/MySportsMHL") {
- @Override
- protected void addExtensions() {
- getLeague().addPlayerExtension("position", "java.lang.String", "FLEX_1");
- }
- };
-
- public static void populateAll(HostedLeagueRepository repository) {
- repository.merge(OSL.getLeague());
- repository.merge(KFL.getLeague());
- repository.merge(MHL.getLeague());
- repository.merge(HTHL.getLeague());
- createStyles(repository);
- }
-
- public static void clearDatabase(EntityManagerFactory emf) {
- EntityManager em = emf.createEntityManager();
-
- try {
- em.getTransaction().begin();
- em.createNativeQuery("DELETE FROM mys_admin_player_ext").executeUpdate();
- em.createNativeQuery("DELETE FROM mys_admin_team_ext").executeUpdate();
- em.createNativeQuery("DELETE FROM mys_admin_div_ext").executeUpdate();
- em.createQuery("DELETE FROM HostedLeague").executeUpdate();
- em.createQuery("DELETE FROM Style").executeUpdate();
- em.getTransaction().commit();
- } finally {
- em.close();
- }
- }
-
- public static void createStyles(HostedLeagueRepository repository) {
- repository.createStyle("default", load("blue"));
- repository.createStyle("red", load("red"));
- repository.createStyle("black", load("black"));
- repository.createStyle("blue", load("blue"));
- repository.createStyle("green", load("green"));
- }
-
- private static String load(String name) {
- String resource = name + ".css";
- InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
-
- if (in == null) {
- Assert.fail("Could not find CSS for '" + name + " @ " + resource);
- }
- try {
- StringWriter writer = new StringWriter(in.available());
- for (int ch = in.read(); ch >= 0; ch = in.read()) {
- writer.write(ch);
- }
- return writer.toString();
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- } finally {
- try {
- in.close();
- } catch (IOException e) {
- }
- }
-
- }
+ private HostedLeague league;
+
+ public ExampleLeagueDefinition(String id, String name, String scheme,
+ String logoUrl, String dataSource) {
+ this.league = new HostedLeague(id, name, scheme);
+ this.league.setLogoUrl(logoUrl);
+ this.league.setDatasourceName(dataSource);
+ addExtensions();
+ }
+
+ public HostedLeague getLeague() {
+ return league;
+ }
+
+ protected abstract void addExtensions();
+
+ public static ExampleLeagueDefinition OSL = new ExampleLeagueDefinition(
+ "OSL", "Ottawa Soccer League", "black", "/logos/osl.png",
+ "jdbc/MySports") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("allergies", "java.lang.String",
+ "FLEX_1");
+ }
+ };
+
+ public static ExampleLeagueDefinition HTHL = new ExampleLeagueDefinition(
+ "HTHL", "High Tech Hockey League", "red", "/logos/hthl.png",
+ "jdbc/MySports") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("position", "java.lang.String",
+ "FLEX_1");
+ getLeague().addPlayerExtension("penaltyMinutes",
+ "java.lang.Integer", "FLEX_2");
+ }
+ };
+
+ public static ExampleLeagueDefinition KFL = new ExampleLeagueDefinition(
+ "KFL", "Kid's Football League", "green", "/logos/kfl.png",
+ "jdbc/MySports") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("position", "java.lang.String",
+ "FLEX_1");
+ }
+ };
+
+ public static ExampleLeagueDefinition MHL = new ExampleLeagueDefinition(
+ "MHL", "Minor Hockey League", "red", "/logos/mhl.png",
+ "jdbc/MySportsMHL") {
+ @Override
+ protected void addExtensions() {
+ getLeague().addPlayerExtension("position", "java.lang.String",
+ "FLEX_1");
+ }
+ };
+
+ public static void populateAll(HostedLeagueRepository repository) {
+ repository.create(OSL.getLeague());
+ repository.create(KFL.getLeague());
+ repository.create(MHL.getLeague());
+ repository.create(HTHL.getLeague());
+ createStyles(repository);
+ }
+
+ public static void clearDatabase(EntityManagerFactory emf) {
+ EntityManager em = emf.createEntityManager();
+
+ try {
+ em.getTransaction().begin();
+ em.createNativeQuery("DELETE FROM mys_admin_player_ext")
+ .executeUpdate();
+ em.createNativeQuery("DELETE FROM mys_admin_team_ext")
+ .executeUpdate();
+ em.createNativeQuery("DELETE FROM mys_admin_div_ext")
+ .executeUpdate();
+ em.createQuery("DELETE FROM HostedLeague").executeUpdate();
+ em.createQuery("DELETE FROM Style").executeUpdate();
+ em.getTransaction().commit();
+ } finally {
+ em.close();
+ }
+ }
+
+ public static void createStyles(HostedLeagueRepository repository) {
+ repository.createStyle("default", load("blue"));
+ repository.createStyle("red", load("red"));
+ repository.createStyle("black", load("black"));
+ repository.createStyle("blue", load("blue"));
+ repository.createStyle("green", load("green"));
+ }
+
+ private static String load(String name) {
+ String resource = name + ".css";
+ InputStream in = Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream(resource);
+
+ if (in == null) {
+ Assert.fail("Could not find CSS for '" + name + " @ " + resource);
+ }
+ try {
+ StringWriter writer = new StringWriter(in.available());
+ for (int ch = in.read(); ch >= 0; ch = in.read()) {
+ writer.write(ch);
+ }
+ return writer.toString();
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ } finally {
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ }
+
+ }
}
diff --git a/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepository.java b/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepository.java
index 8173b21..06a227f 100644
--- a/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepository.java
+++ b/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepository.java
@@ -42,4 +42,6 @@ public interface HostedLeagueRepository {
HostedLeague merge(HostedLeague league);
Style createStyle(String name, String css);
+
+ void create(HostedLeague league);
}
diff --git a/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepositoryBean.java b/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepositoryBean.java
index f006177..b59be7a 100644
--- a/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepositoryBean.java
+++ b/admin.services/src/main/java/eclipselink/example/mysports/admin/services/HostedLeagueRepositoryBean.java
@@ -54,10 +54,20 @@ public class HostedLeagueRepositoryBean implements HostedLeagueRepository {
}
public HostedLeague merge(HostedLeague league) {
+ HostedLeague existingLeague = getEntityManager().find(HostedLeague.class, league.getId());
+
+ if (existingLeague == null) {
+ throw new IllegalStateException("Could not find league: " + league.getId());
+ }
return getEntityManager().merge(league);
}
@Override
+ public void create(HostedLeague league) {
+ getEntityManager().persist(league);
+ }
+
+ @Override
public Style createStyle(String name, String css) {
Style style = new Style(name, css);
return getEntityManager().merge(style);
diff --git a/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/AdminPersistenceTesting.java b/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/AdminPersistenceTesting.java
index d5f69e5..bb972be 100644
--- a/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/AdminPersistenceTesting.java
+++ b/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/AdminPersistenceTesting.java
@@ -39,59 +39,76 @@ import eclipselink.example.mysports.test.common.ExamplePropertiesLoader;
public class AdminPersistenceTesting {
- public static Map<String, Object> add(Map<String, Object> properties) {
- Map<String, Object> props = properties;
-
- if (props == null) {
- props = new HashMap<String, Object>();
- }
- props.put(TRANSACTION_TYPE, "RESOURCE_LOCAL");
- props.put(NON_JTA_DATASOURCE, "");
-
- props.put(CONNECTION_POOL_READ + CONNECTION_POOL_INITIAL, "1");
- props.put(CONNECTION_POOL_READ + CONNECTION_POOL_MIN, "1");
- props.put(CONNECTION_POOL + CONNECTION_POOL_INITIAL, "1");
- props.put(CONNECTION_POOL + CONNECTION_POOL_MIN, "1");
-
- ExamplePropertiesLoader.loadProperties(props);
-
- return props;
- }
-
- public static Map<String, Object> get() {
- return add(null);
- }
-
- public static HostedLeagueRepository createTestRepository(boolean replaceSchema) {
- EntityManagerFactory emf = Persistence.createEntityManagerFactory("MySportsAdmin", get());
- if (replaceSchema) {
- AdminSchemaManager.createTables(emf);
- }
- HostedLeagueRepository repository = (HostedLeagueRepository) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] { HostedLeagueRepository.class }, new HostedLeagueRepositoryHandler(emf));
- ExampleLeagueDefinition.populateAll(repository);
- return repository;
- }
-
- public static EntityManagerFactory getEMF(HostedLeagueRepository repository) {
- HostedLeagueRepositoryHandler handler = (HostedLeagueRepositoryHandler) Proxy.getInvocationHandler(repository);
- return handler.getEmf();
- }
-
- public static void closeTestingRepository(HostedLeagueRepository repository, boolean dropTables) {
- EntityManagerFactory emf = getEMF(repository);
- if (dropTables) {
- dropTables(emf);
- }
- emf.close();
- }
-
- public static void dropTables(EntityManagerFactory emf) {
- Server session = JpaHelper.getServerSession(emf);
- SchemaManager sm = new SchemaManager(session);
-
- TableCreator tc = new DefaultTableGenerator(session.getProject(), true).generateDefaultTableCreator();
- tc.setIgnoreDatabaseException(true);
- tc.dropTables(session, sm, true);
- }
+ public static Map<String, Object> add(Map<String, Object> properties) {
+ Map<String, Object> props = properties;
+
+ if (props == null) {
+ props = new HashMap<String, Object>();
+ }
+ props.put(TRANSACTION_TYPE, "RESOURCE_LOCAL");
+ props.put(NON_JTA_DATASOURCE, "");
+
+ props.put(CONNECTION_POOL_READ + CONNECTION_POOL_INITIAL, "1");
+ props.put(CONNECTION_POOL_READ + CONNECTION_POOL_MIN, "1");
+ props.put(CONNECTION_POOL + CONNECTION_POOL_INITIAL, "1");
+ props.put(CONNECTION_POOL + CONNECTION_POOL_MIN, "1");
+
+ ExamplePropertiesLoader.loadProperties(props);
+
+ return props;
+ }
+
+ public static Map<String, Object> get() {
+ return add(null);
+ }
+
+ public static HostedLeagueRepository createTestRepository(
+ boolean replaceSchema, boolean populate) {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(
+ "MySportsAdmin", get());
+ if (replaceSchema) {
+ AdminSchemaManager.createTables(emf);
+ }
+ HostedLeagueRepository repository = (HostedLeagueRepository) Proxy
+ .newProxyInstance(Thread.currentThread()
+ .getContextClassLoader(),
+ new Class[] { HostedLeagueRepository.class },
+ new HostedLeagueRepositoryHandler(emf));
+
+ if (populate) {
+ ExampleLeagueDefinition.populateAll(repository);
+ }
+ return repository;
+ }
+
+ public static HostedLeagueRepository createTestRepository(
+ boolean replaceSchema) {
+ return createTestRepository(replaceSchema, true);
+ }
+
+ public static EntityManagerFactory getEMF(HostedLeagueRepository repository) {
+ HostedLeagueRepositoryHandler handler = (HostedLeagueRepositoryHandler) Proxy
+ .getInvocationHandler(repository);
+ return handler.getEmf();
+ }
+
+ public static void closeTestingRepository(
+ HostedLeagueRepository repository, boolean dropTables) {
+ EntityManagerFactory emf = getEMF(repository);
+ if (dropTables) {
+ dropTables(emf);
+ }
+ emf.close();
+ }
+
+ public static void dropTables(EntityManagerFactory emf) {
+ Server session = JpaHelper.getServerSession(emf);
+ SchemaManager sm = new SchemaManager(session);
+
+ TableCreator tc = new DefaultTableGenerator(session.getProject(), true)
+ .generateDefaultTableCreator();
+ tc.setIgnoreDatabaseException(true);
+ tc.dropTables(session, sm, true);
+ }
}
diff --git a/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateDatabase.java b/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateDatabase.java
index e1a1bb2..83cffb7 100644
--- a/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateDatabase.java
+++ b/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateDatabase.java
@@ -47,7 +47,7 @@ public class TestCreateDatabase {
HostedLeagueRepository repository= null;
try {
- repository = AdminPersistenceTesting.createTestRepository(true);
+ repository = AdminPersistenceTesting.createTestRepository(true, false);
} finally {
if (repository != null) {
AdminPersistenceTesting.closeTestingRepository(repository, false);
@@ -63,7 +63,7 @@ public class TestCreateDatabase {
HostedLeagueRepository repository= null;
try {
- repository = AdminPersistenceTesting.createTestRepository(true);
+ repository = AdminPersistenceTesting.createTestRepository(true, false);
EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
EntityManager em = emf.createEntityManager();
@@ -89,6 +89,8 @@ public class TestCreateDatabase {
properties.put(PersistenceUnitProperties.SESSION_CUSTOMIZER, EnableIntegrityChecker.class.getName());
properties.put(PersistenceUnitProperties.DEPLOY_ON_STARTUP, Boolean.TRUE.toString());
+ properties.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.DROP_AND_CREATE);
+ properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE, PersistenceUnitProperties.DDL_DATABASE_GENERATION);
EntityManagerFactory emf = null;
try {
diff --git a/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateLeagues.java b/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateLeagues.java
index 2cdcd72..926788f 100644
--- a/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateLeagues.java
+++ b/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestCreateLeagues.java
@@ -51,7 +51,7 @@ public class TestCreateLeagues {
@BeforeClass
public static void createRespository() {
- repository = AdminPersistenceTesting.createTestRepository(true);
+ repository = AdminPersistenceTesting.createTestRepository(true, false);
}
@AfterClass
diff --git a/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestHostedLeagueRepository.java b/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestHostedLeagueRepository.java
index 40d13d5..cdca89b 100644
--- a/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestHostedLeagueRepository.java
+++ b/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/TestHostedLeagueRepository.java
@@ -15,8 +15,6 @@ package eclipselink.example.mysports.admin.services.test;
import java.lang.reflect.Proxy;
import java.util.List;
-import javax.persistence.EntityManagerFactory;
-
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -41,7 +39,7 @@ public class TestHostedLeagueRepository {
@Test
public void verifySchema() {
- EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
+ //EntityManagerFactory emf = AdminPersistenceTesting.getEMF(repository);
}
@@ -118,7 +116,7 @@ public class TestHostedLeagueRepository {
@BeforeClass
public static void createRespository() {
- repository = AdminPersistenceTesting.createTestRepository(true);
+ repository = AdminPersistenceTesting.createTestRepository(true, false);
ExampleLeagueDefinition.populateAll(repository);
}
diff --git a/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/extensions/TestCreateOrmXml.java b/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/extensions/TestCreateOrmXml.java
index d6e2749..a1b064f 100644
--- a/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/extensions/TestCreateOrmXml.java
+++ b/admin.services/src/test/java/eclipselink/example/mysports/admin/services/test/extensions/TestCreateOrmXml.java
@@ -57,7 +57,6 @@ public class TestCreateOrmXml {
@BeforeClass
public static void createRespository() {
repository = AdminPersistenceTesting.createTestRepository(true);
- ExampleLeagueDefinition.populateAll(repository);
}
@AfterClass
diff --git a/admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/HostedLeaguesService.java b/admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/HostedLeaguesService.java
index 8b6cf6a..f7c8f76 100644
--- a/admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/HostedLeaguesService.java
+++ b/admin.web/src/main/java/eclipselink/example/mysports/admin/jaxrs/HostedLeaguesService.java
@@ -44,65 +44,68 @@ import eclipselink.example.mysports.admin.services.HostedLeagueRepository;
@Path("league")
public class HostedLeaguesService {
- @EJB
- private HostedLeagueRepository repository;
-
- public HostedLeagueRepository getRepository() {
- return repository;
- }
-
- public void setRepository(HostedLeagueRepository repository) {
- this.repository = repository;
- }
-
- @GET
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public List<HostedLeague> allLeagues(@Context UriInfo context) {
- List<HostedLeague> allLeagues = getRepository().allSharedLeagues();
-
- for (HostedLeague hl : allLeagues) {
- hl.setUri(context.getAbsolutePath() + "/" + hl.getId());
- }
- return allLeagues;
- }
-
- @GET
- @Path("{league}")
- @Produces(MediaType.APPLICATION_XML)
- public HostedLeague getLeague(@Context UriInfo context, @PathParam("league") String leagueId) {
- HostedLeague league = getRepository().getLeague(leagueId);
- if (league != null && context != null) {
- league.setUri(context.getAbsolutePath() + "/" + league.getId());
- }
- return league;
-
- }
-
- @POST
- public Response create(@FormParam("league-id") String id, @FormParam("league-name") String name, @FormParam("colour-scheme") String scheme) {
- HostedLeague league = getRepository().merge(new HostedLeague(id, name, scheme));
- return Response.status(Response.Status.CREATED).build();
- }
-
- @GET
- @Path("{league}/orm")
- @Produces(MediaType.APPLICATION_XML)
- public String getORM(@PathParam("league") String leagueId) {
- return getRepository().getORM(leagueId);
- }
-
- @GET
- @Path("{league}.css")
- @Produces("text/css")
- public String getCSS(@PathParam("league") String leagueId) {
- return getRepository().getCSS(leagueId);
- }
-
- @GET
- @Path("{league}.png")
- @Produces("image/jpeg")
- public InputStream getLogo(@PathParam("league") String leagueId) {
- return getRepository().getLogo(leagueId);
- }
+ @EJB
+ private HostedLeagueRepository repository;
+
+ public HostedLeagueRepository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(HostedLeagueRepository repository) {
+ this.repository = repository;
+ }
+
+ @GET
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public List<HostedLeague> allLeagues(@Context UriInfo context) {
+ List<HostedLeague> allLeagues = getRepository().allSharedLeagues();
+
+ for (HostedLeague hl : allLeagues) {
+ hl.setUri(context.getAbsolutePath() + "/" + hl.getId());
+ }
+ return allLeagues;
+ }
+
+ @GET
+ @Path("{league}")
+ @Produces(MediaType.APPLICATION_XML)
+ public HostedLeague getLeague(@Context UriInfo context,
+ @PathParam("league") String leagueId) {
+ HostedLeague league = getRepository().getLeague(leagueId);
+ if (league != null && context != null) {
+ league.setUri(context.getAbsolutePath() + "/" + league.getId());
+ }
+ return league;
+
+ }
+
+ @POST
+ public Response create(@FormParam("league-id") String id,
+ @FormParam("league-name") String name,
+ @FormParam("colour-scheme") String scheme) {
+ getRepository().merge(new HostedLeague(id, name, scheme));
+ return Response.status(Response.Status.CREATED).build();
+ }
+
+ @GET
+ @Path("{league}/orm")
+ @Produces(MediaType.APPLICATION_XML)
+ public String getORM(@PathParam("league") String leagueId) {
+ return getRepository().getORM(leagueId);
+ }
+
+ @GET
+ @Path("{league}.css")
+ @Produces("text/css")
+ public String getCSS(@PathParam("league") String leagueId) {
+ return getRepository().getCSS(leagueId);
+ }
+
+ @GET
+ @Path("{league}.png")
+ @Produces("image/jpeg")
+ public InputStream getLogo(@PathParam("league") String leagueId) {
+ return getRepository().getLogo(leagueId);
+ }
} \ No newline at end of file
diff --git a/application/.classpath b/application/.classpath
index bd9c0f4..1f459f9 100644
--- a/application/.classpath
+++ b/application/.classpath
@@ -32,6 +32,7 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
+ <attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
diff --git a/application/.settings/org.eclipse.jpt.core.prefs b/application/.settings/org.eclipse.jpt.core.prefs
index 98ec593..f225875 100644
--- a/application/.settings/org.eclipse.jpt.core.prefs
+++ b/application/.settings/org.eclipse.jpt.core.prefs
@@ -2,3 +2,6 @@ eclipse.preferences.version=1
org.eclipse.jpt.core.platform=eclipselink2_4
org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=false
org.eclipse.jpt.jpa.core.metamodelSourceFolderName=src/main/java
+problem.PROJECT_INACTIVE_CONNECTION=info
+problem.PROJECT_NO_CONNECTION=info
+workspace_preferences_overriden=true
diff --git a/application/pom.xml b/application/pom.xml
index 4509416..5c1f9a0 100644
--- a/application/pom.xml
+++ b/application/pom.xml
@@ -84,6 +84,12 @@
<version>6.0</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.2_15</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
@@ -112,7 +118,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
- <argLine>-javaagent:${user.home}\\.m2\\repository\\eclipselink\\example\\mysports\\persistence\\${eclipselink.version}\\persistence-${eclipselink.version}.jar</argLine>
+ <argLine>-javaagent:${user.home}/.m2/repository/eclipselink/example/mysports/persistence/${eclipselink.version}/persistence-${eclipselink.version}.jar</argLine>
</configuration>
</plugin>
</plugins>
diff --git a/application/src/main/webapp/WEB-INF/faces-config.xml b/application/src/main/webapp/WEB-INF/faces-config.xml
index 7cd6d8e..2c9345f 100644
--- a/application/src/main/webapp/WEB-INF/faces-config.xml
+++ b/application/src/main/webapp/WEB-INF/faces-config.xml
@@ -5,7 +5,7 @@
version="2.0">
<lifecycle>
- <phase-listener>example.mysports.web.jsf.MySportsPhaseListener</phase-listener>
+ <phase-listener>eclipselink.example.mysports.application.view.MySportsPhaseListener</phase-listener>
</lifecycle>
</faces-config>
diff --git a/application/src/main/webapp/leagues-template.jsf b/application/src/main/webapp/leagues-template.jsf
index 8139491..33562a2 100644
--- a/application/src/main/webapp/leagues-template.jsf
+++ b/application/src/main/webapp/leagues-template.jsf
@@ -6,7 +6,6 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fmt="http://java.sun.com/jstl/fmt">
-<f:loadBundle basename="resources.application" var="msg" />
<head>
<title><ui:insert name="title" />
</title>

Back to the top