// create abd configure all the DAOs:
JPAPushApplicationDao pushApplicationDao = new JPAPushApplicationDao();
// generic variant DAO:
JPAVariantDao variantDao = new JPAVariantDao();
pushApplicationDao.setEntityManager(entityManager);
variantDao.setEntityManager(entityManager);
this.installationDao = new JPAInstallationDao();
this.installationDao.setEntityManager(entityManager);
// create the PushApplication and a few variants:
PushApplication pa = new PushApplication();
pa.setName("PushApplication");
pushApplicationDao.create(pa);
AndroidVariant av = new AndroidVariant();
av.setGoogleKey("Key");
av.setName("Android");
av.setDeveloper("me");
// stash the ID:
this.androidVariantID = av.getVariantID();
variantDao.create(av);
SimplePushVariant sp = new SimplePushVariant();
sp.setDeveloper("me");
sp.setName("SimplePush");
// stash the ID:
this.simplePushVariantID = sp.getVariantID();
variantDao.create(sp);
// register the variants with the Push Application:
pa.getVariants().add(av);
pa.getVariants().add(sp);
pushApplicationDao.update(pa);
// ============== Android client installations =========
Installation android1 = new Installation();
android1.setAlias("foo@bar.org");
android1.setDeviceToken(DEVICE_TOKEN_1);
android1.setDeviceType("Android Phone");
final Set<Category> categoriesOne = new HashSet<Category>();
categoriesOne.add(new Category("soccer"));
android1.setCategories(categoriesOne);
installationDao.create(android1);
Installation android2 = new Installation();
android2.setAlias("foo@bar.org");
android2.setDeviceToken(DEVICE_TOKEN_2);
android2.setDeviceType("Android Tablet");
final Set<Category> categoriesTwo = new HashSet<Category>();
categoriesTwo.add(new Category("news"));
android2.setCategories(categoriesTwo);
installationDao.create(android2);
// disabled
Installation android3 = new Installation();
android3.setAlias("foo@bar.org");
android3.setDeviceToken("543234234890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
android3.setDeviceType("Android Tablet");
android3.setEnabled(false);
installationDao.create(android3);
// register them:
android1.setVariant(av);
android2.setVariant(av);
android3.setVariant(av);
variantDao.update(av);
// ============== SimplePush client installations =========
Installation simplePush1 = new Installation();
simplePush1.setAlias("foo@bar.org");
simplePush1.setDeviceToken("http://server:8080/update/" + UUID.randomUUID().toString());
simplePush1.setCategories(categoriesOne);
installationDao.create(simplePush1);
Installation simplePush2 = new Installation();
simplePush2.setAlias("foo@bar.org");
simplePush2.setDeviceToken("http://server:8080/update/" + UUID.randomUUID().toString());
simplePush2.setCategories(categoriesTwo);
installationDao.create(simplePush2);
Installation simplePush3 = new Installation();
simplePush3.setAlias("foo@bar.org");
simplePush3.setDeviceToken("http://server:8080/update/" + UUID.randomUUID().toString());
simplePush3.setCategories(categoriesTwo);
simplePush3.setDeviceType("JavaFX Monitor");
installationDao.create(simplePush3);
// register the installation:
simplePush1.setVariant(sp);
simplePush2.setVariant(sp);
simplePush3.setVariant(sp);
variantDao.update(sp);
}