Commit 40460148b49364c66c4e05954af26ae372c9b3da

Authored by mfcb
1 parent 5de3209e

Merged latest changes.

# Conflicts:
#	services/MainBot/src/main/java/de/bht/beuthbot/scheduler/SchedulerBean.java
#	services/MainBot/src/main/java/de/bht/beuthbot/scheduler/model/Reminder.java
#	services/MainBot/src/main/resources/de/bht/beuthbot/drools/Canteen.drl
services/Common/src/main/java/de/bht/beuthbot/model/entities/Reminder.java
... ... @@ -4,6 +4,7 @@ import de.bht.beuthbot.model.Messenger;
4 4 import de.bht.beuthbot.model.enumeration.ReminderCycle;
5 5  
6 6 import java.time.LocalDate;
  7 +import java.time.LocalDateTime;
7 8 import java.util.Map;
8 9  
9 10 /**
... ... @@ -19,9 +20,9 @@ public interface Reminder extends EntityBase {
19 20  
20 21 void setReminderCycle(ReminderCycle reminderCycle);
21 22  
22   - LocalDate getCycleTime();
  23 + LocalDateTime getCycleDate();
23 24  
24   - void setCycleTime(LocalDate cycleTime);
  25 + void setCycleDate(LocalDateTime cycleDate);
25 26  
26 27 Messenger getMessenger();
27 28  
... ...
services/Common/src/main/java/de/bht/beuthbot/model/entities/ReminderImpl.java
... ... @@ -8,6 +8,7 @@ import javax.persistence.ElementCollection;
8 8 import javax.persistence.Entity;
9 9 import javax.persistence.Table;
10 10 import java.time.LocalDate;
  11 +import java.time.LocalDateTime;
11 12 import java.util.Map;
12 13  
13 14 /**
... ... @@ -21,7 +22,7 @@ public class ReminderImpl extends EntityBaseImpl implements Reminder {
21 22  
22 23 private ReminderCycle reminderCycle;
23 24  
24   - private LocalDate cycleTime;
  25 + private LocalDateTime cycleDate;
25 26  
26 27 private Messenger messenger;
27 28  
... ... @@ -52,13 +53,13 @@ public class ReminderImpl extends EntityBaseImpl implements Reminder {
52 53 }
53 54  
54 55 @Override
55   - public LocalDate getCycleTime() {
56   - return cycleTime;
  56 + public LocalDateTime getCycleDate() {
  57 + return cycleDate;
57 58 }
58 59  
59 60 @Override
60   - public void setCycleTime(LocalDate cycleTime) {
61   - this.cycleTime = cycleTime;
  61 + public void setCycleDate(LocalDateTime cycleDate) {
  62 + this.cycleDate = cycleDate;
62 63 }
63 64  
64 65 @Override
... ...
services/MainBot/src/main/java/de/bht/beuthbot/scheduler/SchedulerBean.java
... ... @@ -2,14 +2,15 @@ package de.bht.beuthbot.scheduler;
2 2  
3 3 import de.bht.beuthbot.attachments.AttachmentStore;
4 4 import de.bht.beuthbot.daos.AppUserDAO;
  5 +import de.bht.beuthbot.daos.ReminderDAO;
5 6 import de.bht.beuthbot.jms.Target;
6 7 import de.bht.beuthbot.model.Attachment;
7 8 import de.bht.beuthbot.model.EntityName;
8 9 import de.bht.beuthbot.model.Intent;
9 10 import de.bht.beuthbot.model.Messenger;
10 11 import de.bht.beuthbot.model.entities.AppUser;
11   -import de.bht.beuthbot.scheduler.model.Reminder;
12   -import de.bht.beuthbot.scheduler.model.ReminderCycle;
  12 +import de.bht.beuthbot.model.entities.Reminder;
  13 +import de.bht.beuthbot.model.enumeration.ReminderCycle;
13 14 import de.bht.beuthbot.utils.DateStringExtractor;
14 15 import org.slf4j.Logger;
15 16 import org.slf4j.LoggerFactory;
... ... @@ -228,16 +229,21 @@ public class SchedulerBean {
228 229 logger.debug("Creating reminder with date " + cycleDate.toString() + " and time " + cycleTime.minusHours(1).toString()); //For some reason the server time is off by an hour, so we need to subtract it from the cycleTime
229 230  
230 231 Reminder reminder = reminderDAO.createReminder();
  232 + logger.debug("resulting DAO object: " + reminder);
231 233 reminder.setUserId(user.getId());
232 234 reminder.setReminderCycle(cycle);
233   - reminder.setCycleTime(cycleDate);
  235 + reminder.setCycleDate(cycleDate);
234 236 reminder.setMessenger(messenger);
235 237 reminder.setIntent(intent);
236 238 reminder.setEntities(entities);
237 239  
238   - return reminderDAO.saveOrUpdate(reminder);
  240 + Reminder reminder1 = reminderDAO.saveOrUpdate(reminder);
  241 +
  242 +
  243 +
  244 + return reminder1;
  245 +
239 246  
240   - //TODO: Insert the new Reminder into Database
241 247 }
242 248  
243 249 public boolean deleteReminder(TaskMessage message, AppUser user) {
... ... @@ -246,8 +252,8 @@ public class SchedulerBean {
246 252 List<Reminder> reminders = reminderDAO.findAll();
247 253 logger.debug("Number of reminders: " + reminders.size());
248 254 for(Reminder reminder : reminders) {
249   - logger.debug("Found reminder for this user:" + reminder.getUser().getTelegramUserId());
250   - if(reminder.getUser().getTelegramUserId().equals(user.getTelegramUserId()) || reminder.getUser().getFacebookUserId().equals(user.getFacebookUserId())) {
  255 + logger.debug("Found reminder for this user:" + reminder.getUserId());
  256 + if(reminder.getUserId() == user.getId()) {
251 257 logger.debug("Found reminder of this user");
252 258 reminders.remove(reminder);
253 259 deletedReminders++;
... ...
services/MainBot/src/main/resources/de/bht/beuthbot/drools/Canteen.drl
... ... @@ -32,17 +32,16 @@ import de.bht.beuthbot.drools.model.DroolsMessage;
32 32  
33 33 import de.bht.beuthbot.scheduler.SchedulerBean;
34 34 import de.bht.beuthbot.jms.TaskMessage;
35   -import de.bht.beuthbot.scheduler.model.ReminderCycle;
36 35 import java.util.Date;
37 36 import java.text.SimpleDateFormat;
38 37 import java.text.ParseException;
39 38 import de.bht.beuthbot.model.Messenger;
40   -import de.bht.beuthbot.scheduler.model.Reminder;
41 39  
42 40 import java.time.DayOfWeek;
43 41 import java.time.LocalDate;
44 42 import de.bht.beuthbot.utils.DateStringExtractor;
45   -import java.time.format.DateTimeFormatter;
  43 +import java.time.format.DateTimeFormatter
  44 +import de.bht.beuthbot.model.entities.Reminder;
46 45  
47 46 global de.bht.beuthbot.canteen.model.CanteenData canteenData;
48 47 global de.bht.beuthbot.model.entities.AppUser user;
... ... @@ -139,7 +138,7 @@ rule &quot;Create reminder&quot;
139 138 TaskMessage message = new TaskMessage(m);
140 139 Reminder reminder = s.createReminder(message, user);
141 140 String messageText = "";
142   - if(reminder.getIntent() == Intent.SHOW_FOOD.getText()) {
  141 + if(reminder.getIntent().equals(Intent.SHOW_FOOD.getText())
143 142 messageText = "Ich werde dir " + DateStringExtractor.getGermanWeekDayFromLocalDate(reminder.getCycleDate().toLocalDate(), true) + " um " + reminder.getCycleDate().toLocalTime().format(DateTimeFormatter.ofPattern("HH:mm")) + " Uhr den Mensaplan mitteilen!";
144 143 } else {
145 144 messageText = "Es war mir leider nicht möglich eine Erinnerung für dich anzulegen. Versuche es bitte noch einmal.";
... ...
services/Telegram/src/main/java/de/bht/beuthbot/messenger/telegram/TelegramReceiveAdapter.java
... ... @@ -41,6 +41,7 @@ import javax.ws.rs.Path;
41 41 import javax.ws.rs.core.MediaType;
42 42 import javax.ws.rs.core.Response;
43 43 import java.time.LocalDate;
  44 +import java.time.LocalDateTime;
44 45 import java.util.HashMap;
45 46 import java.util.List;
46 47  
... ... @@ -178,7 +179,7 @@ public class TelegramReceiveAdapter {
178 179 Reminder reminder = reminderDAO.createReminder();
179 180 reminder.setMessenger(Messenger.TELEGRAM);
180 181 reminder.setReminderCycle(ReminderCycle.DAILY);
181   - reminder.setCycleTime(LocalDate.now());
  182 + reminder.setCycleDate(LocalDateTime.now());
182 183 Long userId = userList.get(0).getId();
183 184 reminder.setUserId(userId);
184 185 reminder.setIntent("Intent");
... ...