Example #1
0
 public static Scenario create(
     String name, boolean isPublic, Date expirationDate, String ownerEmail, Boolean isAccepted) {
   Scenario scenario =
       new Scenario(
           name,
           isPublic,
           expirationDate,
           User.find.where().eq("email", ownerEmail).findUnique(),
           isAccepted);
   scenario.save();
   scenario.saveManyToManyAssociations("members");
   return scenario;
 }
Example #2
0
 public static Scenario edit(
     Long scenarioId,
     String newName,
     Boolean newIsPublic,
     Date newExpirationDate,
     Boolean isAccepted) {
   Scenario scenario = find.ref(scenarioId);
   if (newName != null && !newName.equals(scenario.name)) {
     scenario.name = newName;
   }
   if (newIsPublic != null && newIsPublic != scenario.isPublic) {
     scenario.isPublic = newIsPublic;
   }
   if (newExpirationDate != null && !newExpirationDate.equals(scenario.expirationDate)) {
     scenario.expirationDate = newExpirationDate;
   }
   scenario.isAccepted = isAccepted;
   scenario.editedBy = null;
   scenario.save();
   return scenario;
 }