tx.commit();
/*
* Init some scenes and messages.
*/
Scene scene = messageService.startScene(context, "You're talking to the Guard chief", ulrich, inigo, guardChief);
scene.setAlias(guardChief.getKey().getId() + "", "Global Alias for Guard Chief");
scene.setAlias(ulrich.getKey().getId() + "", "Global Alias for Ulrich");
scene.setAlias(ulrich.getKey().getId() + "-" + inigo.getKey().getId(), "My friend");
dao.save(context, scene);
messageService.postSpeech(context, null, ulrich, "Have you seen the mayor ?");
messageService.postSpeech(context, null, ulrich, "Guy, I'm talking to you !");
messageService.postSpeech(context, scene.getKey(), guardChief, "No, Not the last days. I'm worried.");
messageService.postSpeech(context, null, inigo, "I'm sure he's gone with the town gold !");
messageService.postSpeech(context, scene.getKey(), guardChief, "I'm going right now to check the bank !");
scene = messageService.startScene(context, "Guard chief is gone, you're alone in the street", ulrich, inigo);
messageService.postSpeech(context, null, inigo, "OK, wat a stupid guy ...");
messageService.postSpeech(context, null, ulrich, "Yes, we can now deliver our friend from the jail.");
messageService.postSpeech(context, null, inigo, "Let's go ! I'm going to search Hektor");
scene = messageService.startScene(context, "Hektor, Inigo is coming to you at the inn", hektor, inigo);
messageService.postSpeech(context, null, inigo, "You ! Come with me !");
messageService.postSpeech(context, null, hektor, "Huh ?!? OK ...");
// now ulrich scene
messageService.postOFF(context, null, ulrich.getKey(), null, "Is it to late to go to the market ?");
messageService.postOFF(context, null, null, ulrich.getKey(), "No, you can.");
messageService.postOFF(context, null, ulrich.getKey(), null, "So I go to the market");
messageService.postOFF(context, null, null, ulrich.getKey(), "When arriving to market, you see Olukun.");
messageService.postOFF(context, null, ulrich.getKey(), null, "I go talk to him");
scene = messageService.startScene(context, "Olukun, Ulrich is here.", ulrich, olukun);
messageService.postSpeech(context, null, olukun, "Hey ! How do you do ?");
// ...
scene = messageService.startScene(context, "Everybody is here ...", ulrich, olukun, hektor, inigo);
messageService.postSpeech(context, null, inigo, "OK Let's go to the jail !");
messageService.postSpeech(context, null, olukun, "Huh ... wait a minute ...");
{
List<Scene> scenes = dao.asListOfScenes(null, dao.queryScene(campaign.getKey()), null);
if(scenes != null) {
for(Scene seq : scenes) {
System.err.println(seq.getEntity());
final List<Message> messages =
dao.asListOfMessages(null,
dao.queryMessage(seq.getKey()), null,
Message.Properties.TIMESTAMP);
if(messages != null) {
for(Message msg : messages) {
System.err.println(msg.getEntity());
}
}
}
}
}
{
System.err.println("----------- Inigo messages");
final Context context2 = new Context(romain);
final List<SceneSDO> scenes = messageService.getMessages(context2,
campaign.getKey().getId(),
inigo.getKey().getId(), null, null);
if(scenes != null) {
for(SceneSDO sdo : scenes) {
final Scene seq = sdo.getScene();
System.err.println(seq.getEntity());
final List<Message> messages = sdo.getMessages();
if(messages != null) {
for(Message msg : messages) {
System.err.println(msg.getEntity());
}
}
}
}
}
{
System.err.println("----------- Ulrich messages");
final Context context2 = new Context(xavier);
final List<SceneSDO> scenes = messageService.getMessages(context2,
campaign.getKey().getId(),
ulrich.getKey().getId(), null, null);
if(scenes != null) {
for(SceneSDO sdo : scenes) {
final Scene seq = sdo.getScene();
System.err.println(seq.getEntity());
final List<Message> messages = sdo.getMessages();
if(messages != null) {
for(Message msg : messages) {
System.err.println(msg.getEntity());
}
}
}
}
}
{
System.err.println("----------- Olukun messages");
final Context context2 = new Context(arnaud);
final List<SceneSDO> scenes = messageService.getMessages(context2,
campaign.getKey().getId(),
olukun.getKey().getId(), null, null);
if(scenes != null) {
for(SceneSDO sdo : scenes) {
final Scene seq = sdo.getScene();
System.err.println(seq.getEntity());
final List<Message> messages = sdo.getMessages();
if(messages != null) {
for(Message msg : messages) {
System.err.println(msg.getEntity());
}
}
}
}
}
{
System.err.println("----------- Hektor messages");
final Context context2 = new Context(daniel);
final List<SceneSDO> scenes = messageService.getMessages(context2,
campaign.getKey().getId(),
hektor.getKey().getId(), null, null);
if(scenes != null) {
for(SceneSDO sdo : scenes) {
final Scene seq = sdo.getScene();
System.err.println(seq.getEntity());
final List<Message> messages = sdo.getMessages();
if(messages != null) {
for(Message msg : messages) {
System.err.println(msg.getEntity());
}
}
}
}
}
} finally {
if(tx.isActive()) {
tx.rollback();
}
}
}
{
final Transaction tx = datastore.beginTransaction();
try {
final Campaign campaign = campaignService.createCampaign(null, "another thomas' campaign", "Some game", "Some desc", null, thomas);
campaign.setIcon("http://4.bp.blogspot.com/_SniTwfm5BwE/StS30qA7boI/AAAAAAAABpc/1kDwWjGglHI/s320/D%26D4E.jpg");
createNotification(dao, "this is another Notification", campaign.getKey());
dao.save(null, campaign);
tx.commit();
} finally {
if(tx.isActive()) {
tx.rollback();
}
}
}
{
final Transaction tx = datastore.beginTransaction();
try {
final Campaign campaign = campaignService.createCampaign(null, "Campaign 3", "Some game", "Some desc", null, daniel);
campaign.setIcon("http://www.wizards.com/dnd/images/rhod_gallery/95863.jpg");
createNotification(dao, "Please," + daniel.getNickname()+ " make OFF session to define your character", campaign.getKey());
dao.save(null, campaign);
tx.commit();
} finally {
if(tx.isActive()) {
tx.rollback();
}
}
}
{
final Transaction tx = datastore.beginTransaction();
try {
final Campaign campaign = campaignService.createCampaign(null, "Campaign 2", "Some game", "Some desc", null, daniel);
campaign.setIcon("http://4.bp.blogspot.com/_SniTwfm5BwE/StS30qA7boI/AAAAAAAABpc/1kDwWjGglHI/s320/D%26D4E.jpg");
createNotification(dao, "this is another Notification", campaign.getKey());
dao.save(null, campaign);
tx.commit();
} finally {
if(tx.isActive()) {
tx.rollback();
}
}
}
{
final Transaction tx = datastore.beginTransaction();
try {
final Campaign campaign = campaignService.createCampaign(null, "Daniel's Campaign", "Some game", "Some desc", null, daniel);
createNotification(dao, "this is a Notification", campaign.getKey());
final Data.Character joe = createCharacter(dao, campaign, "Joe", thomas);
final Data.Character jack = createCharacter(dao, campaign, "Jack", arnaud);
createNote(dao, jack, joe, "Why this guy is always following me ?!?");
final Data.Character eric = createCharacter(dao, campaign, "Eric", null);
tx.commit();
} finally {
if(tx.isActive()) {
tx.rollback();
}
}
}
}
/*
* Tests for Home
*/
{
final Data.User user1 = createUser(dao, "user1@home.com", "User1");
final Data.User user2 = createUser(dao, "user2@home.com", "User2");
final Data.User user3 = createUser(dao, "user3@home.com", "User3");
final Campaign campaign = campaignService.createCampaign(null, "My Home !", "Some game", "Some desc", null, user3);
final Data.Character char1 = campaignService.createCharacter(null, campaign, "Char1", user1, null, null);
final Data.Character char2 = campaignService.createCharacter(null, campaign, "Char2", user2, null, null);
final Data.Character char3 = campaignService.createCharacter(null, campaign, "Char3", user3, null, null);
Scene scene = messageService.startScene(context, "Intro", char1, char2, char3);
messageService.postSpeech(context, null, char1, "Message 1");
messageService.postSpeech(context, null, char2, "Message 2");
messageService.postSpeech(context, null, char3, "Message 3");
}