-
Notifications
You must be signed in to change notification settings - Fork 2
/
opendf_changes.patch
4601 lines (4300 loc) · 208 KB
/
opendf_changes.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/opendf/README.md b/opendf/README.md
new file mode 100644
index 0000000..7a9d6b7
--- /dev/null
+++ b/opendf/README.md
@@ -0,0 +1,8 @@
+# Open Pythonic Dataflow Dialogue Framework
+
+This is a modified version of [telepathylabsai](https://github.com/telepathylabsai)/**[OpenDF](https://github.com/telepathylabsai/OpenDF)**, licensed under [MIT license](https://github.com/telepathylabsai/OpenDF/blob/main/LICENSE).
+
+Modifications:
+
+- Implemented 90 missing APIs in SMCalFlow.
+- Many bug fixes.
diff --git a/opendf/applications/core/nodes/time_nodes.py b/opendf/applications/core/nodes/time_nodes.py
index e525743..a031247 100644
--- a/opendf/applications/core/nodes/time_nodes.py
+++ b/opendf/applications/core/nodes/time_nodes.py
@@ -4,6 +4,7 @@ Core time nodes.
from typing import Tuple
+from aws_lex_program_synthesis_calendar.utils.graph_util import find_by_function
from opendf.applications.smcalflow.stub_data import HOLIDAYS
from opendf.exceptions.debug_exception import DebugDFException
from opendf.exceptions.df_exception import InvalidOptionException, MissingValueException, InvalidResultException
@@ -131,6 +132,8 @@ def name_to_dow(nm):
def name_to_month(nm):
+ if isinstance(nm, int):
+ return nm
for i, d in enumerate(monthname_full):
if d.lower() == nm.lower() or (len(nm) == 3 and nm.lower() == d[:3].lower()):
return i + 1
@@ -193,10 +196,10 @@ def describe_Pdatetime(t):
elif t.day == m.day and t.year == m.year and t.month == m.month:
s = 'Tomorrow'
else:
- s = days_of_week[t.isoweekday() - 1] + ' %d %s' % (t.day, monthname[t.month - 1])
+ s = days_of_week[t.isoweekday() - 1] + ' %s %d' % (monthname[t.month - 1], t.day)
if t.year != n.year:
s += ' %d' % t.year
- s += ' %d-%02d' % (t.hour, t.minute)
+ s += ' %d:%02d' % (t.hour, t.minute)
return s
@@ -259,7 +262,7 @@ class Time(Node):
return selection
- def to_partialDateTime(self, mode=None):
+ def to_partialDateTime(self):
# assuming no operators around hour/minute. otherwise - use get_op_object()...
return PartialDateTime(hour=self.get_dat('hour'), minute=self.get_dat('minute'))
@@ -421,7 +424,7 @@ class Date(Node):
self.signature.add_sig('month', Int, match_miss=True)
self.signature.add_sig('day', Int, match_miss=True)
self.signature.add_sig('dow', DayOfWeek, match_miss=True)
- self.signature.add_sig('dayOfWeek', DayOfWeek, match_miss=True, prop=True)
+ self.signature.add_sig('dayOfWeek', DayOfWeek, match_miss=True, alias='dow', prop=True)
def generate_sql_where(self, selection, parent_id, **kwargs):
qualifier = kwargs.get("qualifier", EQ())
@@ -458,7 +461,7 @@ class Date(Node):
return 'tomorrow'
return ''
- def to_partialDateTime(self, mode=None):
+ def to_partialDateTime(self):
# assuming no operators around individual field; otherwise, use get_op_object per field.
return PartialDateTime(self.get_dat('year'), self.get_dat('month'), self.get_dat('day'), self.get_dat('dow'))
@@ -565,6 +568,13 @@ class Date(Node):
# return days_of_week[dw - 1]
return super(type(self), self).getattr_yield_msg(attr, val)
+ def fallback_search(self, parent, all_nodes=None, goals=None, do_eval=True, params=None):
+ dates = super().fallback_search(parent, all_nodes, goals, do_eval, params)
+ if not dates:
+ n,d = self.call_construct_eval('Today()', self.context)
+ dates = [n.res]
+ return dates
+
class DateTime(Node):
"""
@@ -574,7 +584,7 @@ class DateTime(Node):
def __init__(self):
super().__init__(type(self))
self.signature.add_sig('date', [Date, DateRange], match_miss=True)
- self.signature.add_sig('time', [Time, TimeRange], match_miss=True)
+ self.signature.add_sig('pos1', [Time, TimeRange], match_miss=True, alias='time')
self.signature.add_sig('dow', DayOfWeek, prop=True)
def generate_sql_where(self, selection, parent_id, **kwargs):
@@ -598,7 +608,7 @@ class DateTime(Node):
def valid_constraint(self):
self.valid_input()
- def to_partialDateTime(self, mode=None):
+ def to_partialDateTime(self):
# Create a PartialTime object from this DateTime.
# this assumes subfields are "simple":
# if there are any qualifiers (LT, GT,...) they are ignored
@@ -615,7 +625,10 @@ class DateTime(Node):
tm = self.input_view('time')
if tm.is_operator():
tm = tm.get_op_object(typs=['Time'])
- hr, mt = tm.get_dat('hour'), tm.get_dat('minute')
+ if tm:
+ hr, mt = tm.get_dat('hour'), tm.get_dat('minute')
+ else:
+ hr, mt = None, None
else:
hr, mt = None, None
return PartialDateTime(yr, mn, dy, dw, hr, mt)
@@ -641,13 +654,14 @@ class DateTime(Node):
# e.g. self=10AM, ref=9AM, op=GT, means:
# originally we had self:GT(9AM) ref:LT(10AM), and the intersection is calculated by checking 9AM.GT(10AM),
# i.e. calling ref.func_GT(self, op=None)
- # ref may be a different type - and may refer to a time interval, rather than a time point.
- # in that case, we check if the END of ref is before self
def func_LT(self, ref):
- return ref.to_partialDateTime('end') < self.to_partialDateTime()
+ from opendf.applications.smcalflow.nodes.objects import Event
+ if isinstance(ref, Event):
+ ref = ref.get_input_views('slot').get_input_views('start')
+ return ref.to_partialDateTime() < self.to_partialDateTime()
def func_GT(self, ref):
- return ref.to_partialDateTime('start') > self.to_partialDateTime()
+ return ref.to_partialDateTime() > self.to_partialDateTime()
# modes:
# - date: enough that date is specific
@@ -681,7 +695,7 @@ class DateTime(Node):
if 'add_prep' in params:
s = 'on ' + s
elif mn is not None and dy is not None:
- s = dw + '%d/%s,' % (dy, monthname[mn - 1])
+ s = dw + f'{monthname[mn - 1]} {dy},'
if 'add_prep' in params:
s = 'on ' + s
elif mn is not None:
@@ -718,6 +732,9 @@ class DateTime(Node):
p = p if p else get_system_datetime()
t, d = nd.input_view('time'), nd.input_view('date')
if t:
+ if t.typename() == 'AND':
+ _t = find_by_function(t, 'Time')
+ t = _t
hr, mt = t.get_time_values_with_default(hr, mt, orgp)
else:
hr = hr if hr else p.hour
@@ -1037,6 +1054,16 @@ class ToDateTimeCTree(Node):
self.set_result(r)
+class Late(Node):
+ def __init__(self):
+ super().__init__()
+
+ def trans_simple(self, top):
+ n, e = self.call_construct('GT(NumberPM(4))', self.context)
+ self.replace_self(n)
+ return n, None
+
+
def trans_to_DateTime(nd, inp_nm):
"""
Transforms an input with a time type (Time, Date, TimeRange, DateRange, DateTimeRange) to DateTime (query).
@@ -1109,7 +1136,8 @@ def datetime_sexp(yr, mn, dy, hr, mt, dw=None, allow_constr=True):
def to_Pdatetime(nd):
- return nd.to_partialDateTime().to_pdatetime(get_system_datetime())
+ now = get_system_datetime()
+ return nd.to_partialDateTime().to_pdatetime(now.year, now.month, now.day, now.hour, now.minute)
def Pdatetime_to_values(d):
diff --git a/opendf/applications/simplification/nodes/smcalflow_nodes.py b/opendf/applications/simplification/nodes/smcalflow_nodes.py
index 8ecdd17..4d35555 100644
--- a/opendf/applications/simplification/nodes/smcalflow_nodes.py
+++ b/opendf/applications/simplification/nodes/smcalflow_nodes.py
@@ -2041,6 +2041,7 @@ class HolidayYear(Node):
class HourMilitary(Node):
def __init__(self):
super().__init__()
+ self.signature.add_sig('hours', Int, True)
self.signature.add_sig('pos1', [Number, Int], alias='hours')
def simplify(self, top, mode):
diff --git a/opendf/applications/smcalflow/database.py b/opendf/applications/smcalflow/database.py
index 5fae521..584c913 100644
--- a/opendf/applications/smcalflow/database.py
+++ b/opendf/applications/smcalflow/database.py
@@ -1,21 +1,23 @@
"""
Class to interact with a relational database specific for the application.
"""
-
+import os
+import warnings
from datetime import datetime, timedelta, time, date
from typing import Sequence, Optional, Dict, List, Tuple
import sqlalchemy
from sqlalchemy import create_engine, MetaData, Table, Column, Integer, String, ForeignKey, DateTime, insert, \
Boolean, select, func, update, delete, text, and_, or_, not_, cast, Date, Float
+from sqlalchemy.exc import SAWarning
+from opendf import defs
from opendf.applications.core.nodes.time_nodes import Pdate_to_date_sexp
from opendf.applications.smcalflow.domain import recipient_to_str_node, event_to_str_node, match_start, match_end, \
attendees_to_str_node, TIME_SUITABLE_FOR_SUBJECT
from opendf.applications.smcalflow.storage import Storage, RecipientEntry, AttendeeEntry, LocationEntry, EventEntry, \
HolidayEntry
-from opendf.applications.smcalflow.stub_data import db_events, db_persons, CURRENT_RECIPIENT_ID, weather_places, \
- place_has_features, CURRENT_RECIPIENT_LOCATION_ID, HOLIDAYS
+
from opendf.exceptions.python_exception import SingletonClassException
from opendf.graph.nodes.node import Node
from opendf.defs import database_connection, database_log, database_future, NODE_COLOR_DB, DB_NODE_TAG, \
@@ -256,7 +258,7 @@ class Database(Storage):
Database.__instance = Database()
return Database.__instance
- def __init__(self, connection_string=None):
+ def __init__(self, connection_string:str=None):
"""
Create the database class.
"""
@@ -264,6 +266,9 @@ class Database(Storage):
raise SingletonClassException()
if connection_string is None:
connection_string = database_connection
+ if connection_string.startswith('sqlite+pysqlite:///'):
+ path = connection_string[len('sqlite+pysqlite:///'):]
+ os.makedirs(os.path.dirname(path), exist_ok=True)
Database.__instance = self
self.engine: sqlalchemy.engine.base.Engine = \
create_engine(connection_string, echo=database_log, future=database_future)
@@ -410,6 +415,11 @@ class Database(Storage):
recipient_graph = self.get_recipient_graph(row.id, d_context)
recipients.append(recipient_graph)
+ if not recipients and defs.ALWAYS_FOUND_RECIPIENT:
+ row = connection.execute(select(Database.RECIPIENT_TABLE)).first()
+ recipient_graph = self.get_recipient_graph(row.id, d_context)
+ recipients.append(recipient_graph)
+
return recipients
def find_recipients_that_match(self, operator, d_context):
@@ -418,7 +428,7 @@ class Database(Storage):
selection = operator.generate_sql()
if selection is not None:
return self._find_recipient_from_operator_query(selection, d_context)
- except:
+ except Exception as e:
pass
recipients = []
with self.engine.connect() as connection:
@@ -486,17 +496,25 @@ class Database(Storage):
:rtype: List[Node]
"""
events = []
- with self.engine.connect() as connection:
+ with self.engine.connect() as connection, warnings.catch_warnings():
+ warnings.simplefilter("ignore", category=SAWarning)
+ if defs.VERBOSE:
+ sql = selection.compile(compile_kwargs={"literal_binds": True})
+ print(sql)
for row in connection.execute(selection):
event_graph = self.get_event_graph(row.id, d_context)
events.append(event_graph)
+ if not events and defs.ALWAYS_FOUND_EVENT:
+ row = connection.execute(select(Database.EVENT_TABLE)).first()
+ event_graph = self.get_event_graph(row.id, d_context)
+ events.append(event_graph)
return events
- def find_events_that_match(self, operator, d_context):
+ def find_events_that_match(self, operator, d_context, order_by=None, asc=True):
try:
if operator is not None:
- selection = operator.generate_sql()
+ selection = operator.generate_sql(order_by, asc)
if selection is not None:
return self._find_events_from_operator_query(selection, d_context)
except:
@@ -556,6 +574,9 @@ class Database(Storage):
def _find_all_holidays_from_selection(self, selection):
holidays = []
with self.engine.connect() as connection:
+ if defs.VERBOSE:
+ sql = selection.compile(compile_kwargs={"literal_binds": True})
+ print(sql)
for row in connection.execute(selection):
holidays.append(HolidayEntry(row.name, row.date))
return holidays
@@ -677,7 +698,8 @@ class Database(Storage):
if event_entry is None:
return None
recipient_nodes = \
- [self.get_recipient_graph(attendee.recipient.identifier, d_context) for attendee in event_entry.attendees]
+ [self.get_recipient_graph(attendee.recipient.identifier, d_context) for attendee in
+ event_entry.attendees]
string_entry = event_to_str_node(event_entry, recipient_nodes)
event_graph, _ = Node.call_construct_eval(string_entry, d_context, constr_tag=NODE_COLOR_DB)
event_graph.tags[DB_NODE_TAG] = 0
@@ -696,6 +718,8 @@ class Database(Storage):
with self.engine.connect() as connection:
selection = select(func.max(self.EVENT_TABLE.columns.id).label("max"))
for row in connection.execute(selection):
+ if row.max is None:
+ return 0
return row.max
def _get_maximum_location_id(self):
@@ -747,7 +771,9 @@ class Database(Storage):
})
return event_has_attendee_data
- def add_event(self, subject, start, end, location, attendees):
+ def add_event(self, subject, start, end, location='online', attendees=None):
+ if attendees is None:
+ attendees = []
location_id = self._get_location_if_exist(location)
organizer_id = self._current_recipient_id
identifier = self._get_maximum_event_id() + 1
@@ -807,7 +833,8 @@ class Database(Storage):
connection.commit()
- self._event_graph.pop(identifier, None) # invalidate cached value
+ event_node = self._event_graph.pop(identifier, None) # invalidate cached value
+ # maybe we should update event in the graph to reflect changes
return self.get_event_entry(identifier)
def delete_event(self, identifier, subject, start, end, location, attendees):
@@ -817,11 +844,19 @@ class Database(Storage):
with self.engine.connect() as connection:
connection.execute(delete(self.EVENT_TABLE).where(self.EVENT_TABLE.columns.id == ev[0].identifier))
+ connection.execute(delete(self.EVENT_HAS_ATTENDEE_TABLE).where(
+ self.EVENT_HAS_ATTENDEE_TABLE.columns.event_id == ev[0].identifier))
connection.commit()
self._event_graph.pop(identifier, None) # invalidate cached value
return ev
+ def empty_event_table(self):
+ with self.engine.connect() as connection:
+ connection.execute(delete(self.EVENT_TABLE))
+ connection.execute(delete(self.EVENT_HAS_ATTENDEE_TABLE))
+ connection.commit()
+
def _select_attendees(self, attendees, threshold, selection):
"""
Adds a where condition to `selection` in order to select only the events whose number of attendees is equal
@@ -903,10 +938,15 @@ class Database(Storage):
if pre_filter is not None:
selection = selection.where(self.EVENT_TABLE.columns.id.in_(set(map(lambda x: x.identifier, pre_filter))))
+ start = str_to_datetime(start)
+ end = str_to_datetime(end)
with self.engine.connect() as connection:
+ # print(compile_selection(selection))
identifiers = []
for row in connection.execute(selection):
- identifiers.append(row.id)
+ e_start, e_end = row[2], row[3] # Fix stupid sqlite DateTime comparison bugs
+ if e_start <= start < e_end or e_start < end <= e_end or start <= e_start < end or start < e_end <= end:
+ identifiers.append(row.id)
return self._get_event_entries(identifiers)
@@ -981,15 +1021,17 @@ class Database(Storage):
return row.count == 0
-def populate_stub_database():
+def populate_stub_database(stub_data=None):
"""
Populates the database based on the data from the ms_domain.py file.
"""
+ if not stub_data:
+ from opendf.applications.smcalflow import stub_data
database = Database.get_instance()
# reads the events from the ms_domain
- people = db_persons
- events = db_events
+ people = stub_data.db_persons
+ events = stub_data.db_events
database.clean_database()
with database.engine.connect() as connection:
recipient_data = []
@@ -1011,7 +1053,7 @@ def populate_stub_database():
location_data = []
event_data = []
event_has_attendee_data = []
- organizer_id = CURRENT_RECIPIENT_ID # for now, the organizer is the current user
+ organizer_id = stub_data.CURRENT_RECIPIENT_ID # for now, the organizer is the current user
for event in events:
event_data.append({
"id": event.id, "subject": event.subject, "location_id": event.location, "organizer_id": organizer_id,
@@ -1029,7 +1071,7 @@ def populate_stub_database():
"show_as_status": event.showas, "response_status": event.accepted
})
- for weather_place in weather_places:
+ for weather_place in stub_data.weather_places:
location_data.append({
'id': len(location_data), 'name': weather_place.name, 'address': weather_place.address,
'latitude': weather_place.latitude, 'longitude': weather_place.longitude,
@@ -1040,7 +1082,7 @@ def populate_stub_database():
feature_data = []
location_has_feature_data = []
possible_features = dict()
- for location_id, features in place_has_features.items():
+ for location_id, features in stub_data.place_has_features.items():
for feature in features:
feature_id = possible_features.get(feature)
if feature_id is None:
@@ -1052,13 +1094,15 @@ def populate_stub_database():
connection.execute(insert(database.LOCATION_TABLE), location_data)
connection.execute(insert(database.PLACE_FEATURE_TABLE), feature_data)
connection.execute(insert(database.PLACE_HAS_FEATURE_TABLE), location_has_feature_data)
-
- if events:
+ if event_data:
connection.execute(insert(database.EVENT_TABLE), event_data)
+ if event_has_attendee_data:
connection.execute(insert(database.EVENT_HAS_ATTENDEE_TABLE), event_has_attendee_data)
- earliest = get_system_datetime().replace(hour=0, minute=0, second=0, microsecond=0)
- latest = earliest + timedelta(days=event_suggestion_period)
+ today = get_system_datetime()
+ previous_days = 14
+ earliest = (today - timedelta(days=previous_days)).replace(hour=0, minute=0, second=0, microsecond=0)
+ latest = today + timedelta(days=event_suggestion_period - previous_days)
interval = timedelta(minutes=minimum_slot_interval)
values = []
@@ -1066,7 +1110,16 @@ def populate_stub_database():
while current < latest:
values.append({Database.POSSIBLE_TIME_TABLE.columns.point_in_time: current})
current += interval
- connection.execute(insert(Database.POSSIBLE_TIME_TABLE, values))
+
+ try:
+ connection.execute(insert(Database.POSSIBLE_TIME_TABLE, values))
+ except Exception:
+ def chunks(l, n):
+ for i in range(0, n):
+ yield l[i::n]
+
+ for batch in chunks(values, 999):
+ connection.execute(insert(Database.POSSIBLE_TIME_TABLE, batch))
# duration values in minutes
maximum_duration = maximum_duration_days * 24 * 60 + minimum_slot_interval
@@ -1079,12 +1132,30 @@ def populate_stub_database():
current_year = get_system_date().year
values = []
for i in range(-1, 10):
- for (day, month), name in HOLIDAYS.items():
+ for (day, month), name in stub_data.HOLIDAYS.items():
values.append({"name": name,
"date": date(year=current_year + i, month=month, day=day)})
connection.execute(insert(Database.HOLIDAY_TABLE, values))
connection.commit()
- database.set_current_recipient_id(CURRENT_RECIPIENT_ID)
- database.set_current_recipient_location_id(CURRENT_RECIPIENT_LOCATION_ID)
+ database.set_current_recipient_id(stub_data.CURRENT_RECIPIENT_ID)
+ database.set_current_recipient_location_id(stub_data.CURRENT_RECIPIENT_LOCATION_ID)
+
+
+def compile_selection(query):
+ try:
+ from sqlalchemy.dialects import sqlite
+ sql = str(query.compile(dialect=sqlite.dialect(), compile_kwargs={'literal_binds': True}))
+ except Exception:
+ # This has special types which cannot be converted to string automatically.
+ compiler = query.compile()
+ variables = {key: str(value.value) for key, value in compiler.binds.items() if not key.startswith('%')}
+ sql = str(query)
+ # Manually replace the variables in the sql statement with their values.
+ # This won't perfectly match the original statement, as this converts everything to str and wraps in double-quotes for simplicity.
+ for variable, value in variables.items():
+ # Variables are prefixed with :
+ # Example: "DELETE FROM table WHERE skill.id = :id_1"
+ sql = sql.replace(f':{variable}', f'"{value}"')
+ return sql
diff --git a/opendf/applications/smcalflow/dialog_stub_data/__init__.py b/opendf/applications/smcalflow/dialog_stub_data/__init__.py
new file mode 100644
index 0000000..595cb77
--- /dev/null
+++ b/opendf/applications/smcalflow/dialog_stub_data/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding:utf-8 -*-
+# Author: hankcs
+# Date: 2022-05-26 09:55
diff --git a/opendf/applications/smcalflow/dialog_stub_data/stub_data_0.py b/opendf/applications/smcalflow/dialog_stub_data/stub_data_0.py
new file mode 100644
index 0000000..60842c3
--- /dev/null
+++ b/opendf/applications/smcalflow/dialog_stub_data/stub_data_0.py
@@ -0,0 +1,103 @@
+"""
+Holds the stub data (concerning the smcalflow application) to test the system.
+"""
+
+from collections import namedtuple
+from datetime import timedelta
+
+from opendf.defs import get_system_date
+
+CURRENT_RECIPIENT_ID = 1007
+CURRENT_RECIPIENT_LOCATION_ID = 7
+
+# not bothering with nicknames for now
+DBPerson = namedtuple(
+ 'DBPerson', ['fullName', 'firstName', 'lastName', 'id', 'phone_number', 'email_address',
+ 'manager_id', 'friends'])
+db_persons = [
+ DBPerson('John Doe', 'John', 'Doe', 1001, '41761231001', 'john.doe@opendf.com', 1006, []), # friend of Adam (current user)
+ DBPerson('Jane Doe', 'Jane', 'Doe', 1002, '41761231002', 'jane.doe@opendf.com', 1003, []),
+ DBPerson('Jon Smith', 'Jon', 'Smith', 1003, '41761231003', 'jon.smith@opendf.com', 1004, []), # friend of Adam (current user)
+ # DBPerson('John_Smith', 'John', 'Smith', 1003, '41761231004', 'john.smith@opendf.com', 1004, []), # friend of Adam (current user)
+ DBPerson('Jane Smith', 'Jane', 'Smith', 1004, '41761231004', 'jane.smith@opendf.com', 1004, []),
+ DBPerson('Jerry Skinner', 'Jerry', 'Skinner', 1005, '41761231005', 'jerry.skinner@opendf.com', 1004, []), # friend of Adam (current user)
+ DBPerson('Dan Smith', 'Dan', 'Smith', 1006, '41761231006', 'dan.smith@opendf.com', 1004, []),
+ DBPerson('Adam Smith', 'Adam', 'Smith', 1007, '41761231007', 'adam.smith@opendf.com', 1004, [1001, 1003, 1004]), # <<<< current user!
+]
+# when looking for a name - if friendship is considered, then "John" is ambiguous, but "Jane" means Jane Smith.
+
+# for demos - we fill the dummy database with values relative to system's date, to avoid having to manually change the
+# dates remember that the coming Friday may be before the coming Wednesday...
+# all of these days are AFTER system's date
+td = get_system_date()
+d0 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 2][0]) # next Tuesday
+d1 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 3][0]) # next Wednesday
+d2 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 4][0]) # next Thursday
+d3 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 5][0]) # next Friday
+d5 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 7][0]) # next Sunday
+
+dTue = '%d/%d/%d/' % (d0.year, d0.month, d0.day) # the coming Tuesday
+dWed = '%d/%d/%d/' % (d1.year, d1.month, d1.day) # the coming Wednesday
+dThu = '%d/%d/%d/' % (d2.year, d2.month, d2.day) # the coming Thursday
+dFri = '%d/%d/%d/' % (d3.year, d3.month, d3.day) # the coming Friday
+dSun = '%d/%d/%d/' % (d5.year, d5.month, d5.day) # the coming Sunday
+
+# TODO: separate between events and calendar
+# each user should have a personal calendar, which has events, and for each event has
+# showAs status and accept/reject flag
+# each event has invitees (and inviter?), but not the status/reply per user
+
+# for multiple attendees - semicolon separated (NOT comma - this interferes with sexp parsing!!)
+DBevent = namedtuple('DBevent', ['id', 'subject', 'start', 'end', 'location', 'attendees', 'accepted', 'showas'])
+
+# This shows the entries in the schedule of a specific user (not included in the attendees)
+db_events = [
+]
+
+WeatherPlace = namedtuple("WeatherPlace",
+ ['id', 'name', 'address', 'latitude', 'longitude', 'radius', 'always_free', 'is_virtual'])
+
+ZURICH_COORDINATES = 47.374444, 8.541111
+BERN_COORDINATES = 46.947633, 7.404997
+TOKYO_COORDINATES = 35.701067, 139.755280
+BARCELONA_COORDINATES = 41.411023, 2.163190
+
+weather_places = [
+ WeatherPlace(0, 'online', "", None, None, None, True, True),
+ WeatherPlace(1, 'room1', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(2, 'room2', "Zürich, Zürich, Switzerland", *BERN_COORDINATES, 20, True, False),
+ WeatherPlace(3, 'room3', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(4, 'room4', "Zürich, Zürich, Switzerland", *BERN_COORDINATES, 20, True, False),
+ WeatherPlace(5, 'room5', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(6, 'jeffs', "Bern, Bern, Switzerland", *BERN_COORDINATES, 20, True, False),
+
+ WeatherPlace(7, 'zurich', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 7500, True, False),
+ WeatherPlace(8, 'bern', "Bern, Bern, Switzerland", *BERN_COORDINATES, 8800, True, False),
+ WeatherPlace(9, 'tokyo', "Tokyo, Kanto, Japan", *TOKYO_COORDINATES, 17000, True, False),
+ WeatherPlace(10, 'barcelona', "Barcelona, Catalonia, Spain", *BARCELONA_COORDINATES, 5700, True, False),
+ WeatherPlace(11, 'letzipark', "", 47.386596, 8.499430, 80, False, False),
+ WeatherPlace(12, 'home', "Bahnhofstrasse 1, 8001 Zürich, Zürich, Switzerland", 47.367436, 8.539832, 30, False, False),
+]
+
+weather_types = ['cloud', 'clear', 'rain', 'snow', 'storm', 'wind', 'sleet']
+
+WEATHER_TABLE = {
+ ZURICH_COORDINATES:
+ ('zurich', [(-2, 'snow'), (0, 'cloud'), (5, 'rain'), (7, 'storm'), (10, 'wind'), (10, 'clear'), (0, 'sleet')]),
+ BERN_COORDINATES:
+ ('bern', [(-5, 'clear'), (-2, 'cloud'), (0, 'snow'), (4, 'rain'), (4, 'rain'), (5, 'cloud'), (0, 'clear')]),
+ TOKYO_COORDINATES:
+ ('tokyo', [(-8, 'snow'), (-6, 'cloud'), (-6, 'snow'), (0, 'cloud'), (-2, 'clear'), (0, 'rain'), (2, 'rain')]),
+ BARCELONA_COORDINATES:
+ ('barcelona', [(13, 'rain'), (17, 'rain'), (18, 'clear'), (20, 'clear'), (18, 'cloud'), (17, 'rain'), (21, 'clear')]),
+}
+
+place_has_features = {
+ 6: ["HappyHour"]
+}
+HOLIDAYS = {
+ (1, 1): "NewYearsDay",
+ (5, 1): "TestDay", # test purpose
+ (25, 12): "Christmas",
+ (31, 12): "NewYearsEve"
+}
\ No newline at end of file
diff --git a/opendf/applications/smcalflow/dialog_stub_data/stub_data_11663.py b/opendf/applications/smcalflow/dialog_stub_data/stub_data_11663.py
new file mode 100644
index 0000000..15bde6a
--- /dev/null
+++ b/opendf/applications/smcalflow/dialog_stub_data/stub_data_11663.py
@@ -0,0 +1,111 @@
+"""
+Holds the stub data (concerning the smcalflow application) to test the system.
+"""
+
+from collections import namedtuple
+from datetime import timedelta
+
+from opendf.defs import get_system_date
+
+CURRENT_RECIPIENT_ID = 1007
+CURRENT_RECIPIENT_LOCATION_ID = 7
+
+# not bothering with nicknames for now
+DBPerson = namedtuple(
+ 'DBPerson', ['fullName', 'firstName', 'lastName', 'id', 'phone_number', 'email_address',
+ 'manager_id', 'friends'])
+db_persons = [
+ DBPerson('John Tim', 'John', 'Tim', 1001, '41761231001', 'john.tim@opendf.com', 1006, []),
+ # friend of Adam (current user)
+ DBPerson('Jane Doe', 'Jane', 'Doe', 1002, '41761231002', 'jane.doe@opendf.com', 1003, []),
+ DBPerson('Jon Smith', 'Jon', 'Smith', 1003, '41761231003', 'jon.smith@opendf.com', 1004, []),
+ # friend of Adam (current user)
+ # DBPerson('John_Smith', 'John', 'Smith', 1003, '41761231004', 'john.smith@opendf.com', 1004, []), # friend of Adam (current user)
+ DBPerson('Jane Smith', 'Jane', 'Smith', 1004, '41761231004', 'jane.smith@opendf.com', 1004, []),
+ DBPerson('Jerry Skinner', 'Jerry', 'Skinner', 1005, '41761231005', 'jerry.skinner@opendf.com', 1004, []),
+ # friend of Adam (current user)
+ DBPerson('Dan Smith', 'Dan', 'Smith', 1006, '41761231006', 'dan.smith@opendf.com', 1004, []),
+ DBPerson('Adam Smith', 'Adam', 'Smith', 1007, '41761231007', 'adam.smith@opendf.com', 1004, [1001, 1003, 1004]),
+ # <<<< current user!
+]
+# when looking for a name - if friendship is considered, then "John" is ambiguous, but "Jane" means Jane Smith.
+
+# for demos - we fill the dummy database with values relative to system's date, to avoid having to manually change the
+# dates remember that the coming Friday may be before the coming Wednesday...
+# all of these days are AFTER system's date
+td = get_system_date()
+d0 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 2][0]) # next Tuesday
+d1 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 3][0]) # next Wednesday
+d2 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 4][0]) # next Thursday
+d3 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 5][0]) # next Friday
+d5 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 7][0]) # next Sunday
+
+dTue = '%d/%d/%d/' % (d0.year, d0.month, d0.day) # the coming Tuesday
+dWed = '%d/%d/%d/' % (d1.year, d1.month, d1.day) # the coming Wednesday
+dThu = '%d/%d/%d/' % (d2.year, d2.month, d2.day) # the coming Thursday
+dFri = '%d/%d/%d/' % (d3.year, d3.month, d3.day) # the coming Friday
+dSun = '%d/%d/%d/' % (d5.year, d5.month, d5.day) # the coming Sunday
+
+# TODO: separate between events and calendar
+# each user should have a personal calendar, which has events, and for each event has
+# showAs status and accept/reject flag
+# each event has invitees (and inviter?), but not the status/reply per user
+
+# for multiple attendees - semicolon separated (NOT comma - this interferes with sexp parsing!!)
+DBevent = namedtuple('DBevent', ['id', 'subject', 'start', 'end', 'location', 'attendees', 'accepted', 'showas'])
+
+# This shows the entries in the schedule of a specific user (not included in the attendees)
+db_events = [
+ DBevent(1, 'staff meeting', dTue + '12/0', dTue + '12/30', 1, [1008, 1007],
+ ['Accepted', 'Accepted', 'Declined'], ['Busy', 'Busy', 'Free']),
+]
+
+WeatherPlace = namedtuple("WeatherPlace",
+ ['id', 'name', 'address', 'latitude', 'longitude', 'radius', 'always_free', 'is_virtual'])
+
+ZURICH_COORDINATES = 47.374444, 8.541111
+BERN_COORDINATES = 46.947633, 7.404997
+TOKYO_COORDINATES = 35.701067, 139.755280
+BARCELONA_COORDINATES = 41.411023, 2.163190
+
+weather_places = [
+ WeatherPlace(0, 'online', "", None, None, None, True, True),
+ WeatherPlace(1, 'room1', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(2, 'room2', "Zürich, Zürich, Switzerland", *BERN_COORDINATES, 20, True, False),
+ WeatherPlace(3, 'room3', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(4, 'room4', "Zürich, Zürich, Switzerland", *BERN_COORDINATES, 20, True, False),
+ WeatherPlace(5, 'room5', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(6, 'jeffs', "Bern, Bern, Switzerland", *BERN_COORDINATES, 20, True, False),
+
+ WeatherPlace(7, 'zurich', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 7500, True, False),
+ WeatherPlace(8, 'bern', "Bern, Bern, Switzerland", *BERN_COORDINATES, 8800, True, False),
+ WeatherPlace(9, 'tokyo', "Tokyo, Kanto, Japan", *TOKYO_COORDINATES, 17000, True, False),
+ WeatherPlace(10, 'barcelona', "Barcelona, Catalonia, Spain", *BARCELONA_COORDINATES, 5700, True, False),
+ WeatherPlace(11, 'letzipark', "", 47.386596, 8.499430, 80, False, False),
+ WeatherPlace(12, 'home', "Bahnhofstrasse 1, 8001 Zürich, Zürich, Switzerland", 47.367436, 8.539832, 30, False,
+ False),
+]
+
+weather_types = ['cloud', 'clear', 'rain', 'snow', 'storm', 'wind', 'sleet']
+
+WEATHER_TABLE = {
+ ZURICH_COORDINATES:
+ ('zurich', [(-2, 'snow'), (0, 'cloud'), (5, 'rain'), (7, 'storm'), (10, 'wind'), (10, 'clear'), (0, 'sleet')]),
+ BERN_COORDINATES:
+ ('bern', [(-5, 'clear'), (-2, 'cloud'), (0, 'snow'), (4, 'rain'), (4, 'rain'), (5, 'cloud'), (0, 'clear')]),
+ TOKYO_COORDINATES:
+ ('tokyo', [(-8, 'snow'), (-6, 'cloud'), (-6, 'snow'), (0, 'cloud'), (-2, 'clear'), (0, 'rain'), (2, 'rain')]),
+ BARCELONA_COORDINATES:
+ ('barcelona',
+ [(13, 'rain'), (17, 'rain'), (18, 'clear'), (20, 'clear'), (18, 'cloud'), (17, 'rain'), (21, 'clear')]),
+}
+
+place_has_features = {
+ 6: ["HappyHour"]
+}
+HOLIDAYS = {
+ (1, 1): "NewYearsDay",
+ (5, 1): "TestDay", # test purpose
+ (25, 12): "Christmas",
+ (31, 12): "NewYearsEve"
+}
diff --git a/opendf/applications/smcalflow/dialog_stub_data/stub_data_13.py b/opendf/applications/smcalflow/dialog_stub_data/stub_data_13.py
new file mode 100644
index 0000000..0cc3187
--- /dev/null
+++ b/opendf/applications/smcalflow/dialog_stub_data/stub_data_13.py
@@ -0,0 +1,113 @@
+"""
+Holds the stub data (concerning the smcalflow application) to test the system.
+"""
+
+from collections import namedtuple
+from datetime import timedelta
+
+from opendf.defs import get_system_date
+
+CURRENT_RECIPIENT_ID = 1007
+CURRENT_RECIPIENT_LOCATION_ID = 7
+
+# not bothering with nicknames for now
+DBPerson = namedtuple(
+ 'DBPerson', ['fullName', 'firstName', 'lastName', 'id', 'phone_number', 'email_address',
+ 'manager_id', 'friends'])
+db_persons = [
+ DBPerson('John Doe', 'John', 'Doe', 1001, '41761231001', 'john.doe@opendf.com', 1006, []),
+ # friend of Adam (current user)
+ DBPerson('Jane Doe', 'Jane', 'Doe', 1002, '41761231002', 'jane.doe@opendf.com', 1003, []),
+ DBPerson('Jon Smith', 'Jon', 'Smith', 1003, '41761231003', 'jon.smith@opendf.com', 1004, []),
+ # friend of Adam (current user)
+ # DBPerson('John_Smith', 'John', 'Smith', 1003, '41761231004', 'john.smith@opendf.com', 1004, []), # friend of Adam (current user)
+ DBPerson('Jane Smith', 'Jane', 'Smith', 1004, '41761231004', 'jane.smith@opendf.com', 1004, []),
+ DBPerson('Jerry Skinner', 'Jerry', 'Skinner', 1005, '41761231005', 'jerry.skinner@opendf.com', 1004, []),
+ # friend of Adam (current user)
+ DBPerson('Dan Smith', 'Dan', 'Smith', 1006, '41761231006', 'dan.smith@opendf.com', 1004, []),
+ DBPerson('Adam Smith', 'Adam', 'Smith', 1007, '41761231007', 'adam.smith@opendf.com', 1004, [1001, 1003, 1004]),
+ # <<<< current user!
+ DBPerson('Janice Kang', 'Janice', 'Kang', 1008, '41761231007', 'Janice.Kang@opendf.com', 1004, [1001, 1003, 1004]),
+ DBPerson('Cher Roydon', 'Cher', 'Roydon', 1009, '41761231007', 'Cher.Roydon@opendf.com', 1004, [1001, 1003, 1004]),
+ DBPerson('Ron Li', 'Ron', 'Li', 1010, '41761231007', 'Ron.Li@opendf.com', 1004, [1001, 1003, 1004]),
+
+]
+# when looking for a name - if friendship is considered, then "John" is ambiguous, but "Jane" means Jane Smith.
+
+# for demos - we fill the dummy database with values relative to system's date, to avoid having to manually change the
+# dates remember that the coming Friday may be before the coming Wednesday...
+# all of these days are AFTER system's date
+td = get_system_date()
+d0 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 2][0]) # next Tuesday
+d1 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 3][0]) # next Wednesday
+d2 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 4][0]) # next Thursday
+d3 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 5][0]) # next Friday
+d5 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 7][0]) # next Sunday
+
+dTue = '%d/%d/%d/' % (d0.year, d0.month, d0.day) # the coming Tuesday
+dWed = '%d/%d/%d/' % (d1.year, d1.month, d1.day) # the coming Wednesday
+dThu = '%d/%d/%d/' % (d2.year, d2.month, d2.day) # the coming Thursday
+dFri = '%d/%d/%d/' % (d3.year, d3.month, d3.day) # the coming Friday
+dSun = '%d/%d/%d/' % (d5.year, d5.month, d5.day) # the coming Sunday
+
+# TODO: separate between events and calendar
+# each user should have a personal calendar, which has events, and for each event has
+# showAs status and accept/reject flag
+# each event has invitees (and inviter?), but not the status/reply per user
+
+# for multiple attendees - semicolon separated (NOT comma - this interferes with sexp parsing!!)
+DBevent = namedtuple('DBevent', ['id', 'subject', 'start', 'end', 'location', 'attendees', 'accepted', 'showas'])
+
+# This shows the entries in the schedule of a specific user (not included in the attendees)
+db_events = [
+]
+
+WeatherPlace = namedtuple("WeatherPlace",
+ ['id', 'name', 'address', 'latitude', 'longitude', 'radius', 'always_free', 'is_virtual'])
+
+ZURICH_COORDINATES = 47.374444, 8.541111
+BERN_COORDINATES = 46.947633, 7.404997
+TOKYO_COORDINATES = 35.701067, 139.755280
+BARCELONA_COORDINATES = 41.411023, 2.163190
+
+weather_places = [
+ WeatherPlace(0, 'online', "", None, None, None, True, True),
+ WeatherPlace(1, 'room1', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(2, 'room2', "Zürich, Zürich, Switzerland", *BERN_COORDINATES, 20, True, False),
+ WeatherPlace(3, 'room3', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(4, 'room4', "Zürich, Zürich, Switzerland", *BERN_COORDINATES, 20, True, False),
+ WeatherPlace(5, 'room5', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(6, 'jeffs', "Bern, Bern, Switzerland", *BERN_COORDINATES, 20, True, False),
+
+ WeatherPlace(7, 'zurich', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 7500, True, False),
+ WeatherPlace(8, 'bern', "Bern, Bern, Switzerland", *BERN_COORDINATES, 8800, True, False),
+ WeatherPlace(9, 'tokyo', "Tokyo, Kanto, Japan", *TOKYO_COORDINATES, 17000, True, False),
+ WeatherPlace(10, 'barcelona', "Barcelona, Catalonia, Spain", *BARCELONA_COORDINATES, 5700, True, False),
+ WeatherPlace(11, 'letzipark', "", 47.386596, 8.499430, 80, False, False),
+ WeatherPlace(12, 'home', "Bahnhofstrasse 1, 8001 Zürich, Zürich, Switzerland", 47.367436, 8.539832, 30, False,
+ False),
+]
+
+weather_types = ['cloud', 'clear', 'rain', 'snow', 'storm', 'wind', 'sleet']
+
+WEATHER_TABLE = {
+ ZURICH_COORDINATES:
+ ('zurich', [(-2, 'snow'), (0, 'cloud'), (5, 'rain'), (7, 'storm'), (10, 'wind'), (10, 'clear'), (0, 'sleet')]),
+ BERN_COORDINATES:
+ ('bern', [(-5, 'clear'), (-2, 'cloud'), (0, 'snow'), (4, 'rain'), (4, 'rain'), (5, 'cloud'), (0, 'clear')]),
+ TOKYO_COORDINATES:
+ ('tokyo', [(-8, 'snow'), (-6, 'cloud'), (-6, 'snow'), (0, 'cloud'), (-2, 'clear'), (0, 'rain'), (2, 'rain')]),
+ BARCELONA_COORDINATES:
+ ('barcelona',
+ [(13, 'rain'), (17, 'rain'), (18, 'clear'), (20, 'clear'), (18, 'cloud'), (17, 'rain'), (21, 'clear')]),
+}
+
+place_has_features = {
+ 6: ["HappyHour"]
+}
+HOLIDAYS = {
+ (1, 1): "NewYearsDay",
+ (5, 1): "TestDay", # test purpose
+ (25, 12): "Christmas",
+ (31, 12): "NewYearsEve"
+}
diff --git a/opendf/applications/smcalflow/dialog_stub_data/stub_data_3.py b/opendf/applications/smcalflow/dialog_stub_data/stub_data_3.py
new file mode 100644
index 0000000..dd78115
--- /dev/null
+++ b/opendf/applications/smcalflow/dialog_stub_data/stub_data_3.py
@@ -0,0 +1,105 @@
+"""
+Holds the stub data (concerning the smcalflow application) to test the system.
+"""
+
+from collections import namedtuple
+from datetime import timedelta
+
+from opendf.defs import get_system_date
+
+CURRENT_RECIPIENT_ID = 1007
+CURRENT_RECIPIENT_LOCATION_ID = 7
+
+# not bothering with nicknames for now
+DBPerson = namedtuple(
+ 'DBPerson', ['fullName', 'firstName', 'lastName', 'id', 'phone_number', 'email_address',
+ 'manager_id', 'friends'])
+db_persons = [
+ DBPerson('John Doe', 'John', 'Doe', 1001, '41761231001', 'john.doe@opendf.com', 1006, []), # friend of Adam (current user)
+ DBPerson('Jane Doe', 'Jane', 'Doe', 1002, '41761231002', 'jane.doe@opendf.com', 1003, []),
+ DBPerson('Jon Smith', 'Jon', 'Smith', 1003, '41761231003', 'jon.smith@opendf.com', 1004, []), # friend of Adam (current user)
+ # DBPerson('John_Smith', 'John', 'Smith', 1003, '41761231004', 'john.smith@opendf.com', 1004, []), # friend of Adam (current user)
+ DBPerson('Jane Smith', 'Jane', 'Smith', 1004, '41761231004', 'jane.smith@opendf.com', 1004, []),
+ DBPerson('Jerry Skinner', 'Jerry', 'Skinner', 1005, '41761231005', 'jerry.skinner@opendf.com', 1004, []), # friend of Adam (current user)
+ DBPerson('Dan Smith', 'Dan', 'Smith', 1006, '41761231006', 'dan.smith@opendf.com', 1004, []),
+ DBPerson('Adam Smith', 'Adam', 'Smith', 1007, '41761231007', 'adam.smith@opendf.com', 1004, [1001, 1003, 1004]), # <<<< current user!
+ DBPerson('Janice Kang', 'Janice', 'Kang', 1008, '41761231007', 'Janice.Kang@opendf.com', 1004, [1001, 1003, 1004]),
+ DBPerson('Cher Roydon', 'Cher', 'Roydon', 1009, '41761231007', 'Cher.Roydon@opendf.com', 1004, [1001, 1003, 1004]),
+]
+# when looking for a name - if friendship is considered, then "John" is ambiguous, but "Jane" means Jane Smith.
+
+# for demos - we fill the dummy database with values relative to system's date, to avoid having to manually change the
+# dates remember that the coming Friday may be before the coming Wednesday...
+# all of these days are AFTER system's date
+td = get_system_date()
+d0 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 2][0]) # next Tuesday
+d1 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 3][0]) # next Wednesday
+d2 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 4][0]) # next Thursday
+d3 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 5][0]) # next Friday
+d5 = td + timedelta(days=[i for i in range(1, 8) if (td + timedelta(days=i)).isoweekday() == 7][0]) # next Sunday
+
+dTue = '%d/%d/%d/' % (d0.year, d0.month, d0.day) # the coming Tuesday
+dWed = '%d/%d/%d/' % (d1.year, d1.month, d1.day) # the coming Wednesday
+dThu = '%d/%d/%d/' % (d2.year, d2.month, d2.day) # the coming Thursday
+dFri = '%d/%d/%d/' % (d3.year, d3.month, d3.day) # the coming Friday
+dSun = '%d/%d/%d/' % (d5.year, d5.month, d5.day) # the coming Sunday
+
+# TODO: separate between events and calendar
+# each user should have a personal calendar, which has events, and for each event has
+# showAs status and accept/reject flag
+# each event has invitees (and inviter?), but not the status/reply per user
+
+# for multiple attendees - semicolon separated (NOT comma - this interferes with sexp parsing!!)
+DBevent = namedtuple('DBevent', ['id', 'subject', 'start', 'end', 'location', 'attendees', 'accepted', 'showas'])
+
+# This shows the entries in the schedule of a specific user (not included in the attendees)
+db_events = [
+]
+
+WeatherPlace = namedtuple("WeatherPlace",
+ ['id', 'name', 'address', 'latitude', 'longitude', 'radius', 'always_free', 'is_virtual'])
+
+ZURICH_COORDINATES = 47.374444, 8.541111
+BERN_COORDINATES = 46.947633, 7.404997
+TOKYO_COORDINATES = 35.701067, 139.755280
+BARCELONA_COORDINATES = 41.411023, 2.163190
+
+weather_places = [
+ WeatherPlace(0, 'online', "", None, None, None, True, True),
+ WeatherPlace(1, 'room1', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(2, 'room2', "Zürich, Zürich, Switzerland", *BERN_COORDINATES, 20, True, False),
+ WeatherPlace(3, 'room3', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(4, 'room4', "Zürich, Zürich, Switzerland", *BERN_COORDINATES, 20, True, False),
+ WeatherPlace(5, 'room5', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 20, True, False),
+ WeatherPlace(6, 'jeffs', "Bern, Bern, Switzerland", *BERN_COORDINATES, 20, True, False),
+
+ WeatherPlace(7, 'zurich', "Zürich, Zürich, Switzerland", *ZURICH_COORDINATES, 7500, True, False),
+ WeatherPlace(8, 'bern', "Bern, Bern, Switzerland", *BERN_COORDINATES, 8800, True, False),
+ WeatherPlace(9, 'tokyo', "Tokyo, Kanto, Japan", *TOKYO_COORDINATES, 17000, True, False),
+ WeatherPlace(10, 'barcelona', "Barcelona, Catalonia, Spain", *BARCELONA_COORDINATES, 5700, True, False),
+ WeatherPlace(11, 'letzipark', "", 47.386596, 8.499430, 80, False, False),
+ WeatherPlace(12, 'home', "Bahnhofstrasse 1, 8001 Zürich, Zürich, Switzerland", 47.367436, 8.539832, 30, False, False),
+]
+
+weather_types = ['cloud', 'clear', 'rain', 'snow', 'storm', 'wind', 'sleet']
+
+WEATHER_TABLE = {
+ ZURICH_COORDINATES:
+ ('zurich', [(-2, 'snow'), (0, 'cloud'), (5, 'rain'), (7, 'storm'), (10, 'wind'), (10, 'clear'), (0, 'sleet')]),
+ BERN_COORDINATES:
+ ('bern', [(-5, 'clear'), (-2, 'cloud'), (0, 'snow'), (4, 'rain'), (4, 'rain'), (5, 'cloud'), (0, 'clear')]),
+ TOKYO_COORDINATES:
+ ('tokyo', [(-8, 'snow'), (-6, 'cloud'), (-6, 'snow'), (0, 'cloud'), (-2, 'clear'), (0, 'rain'), (2, 'rain')]),
+ BARCELONA_COORDINATES:
+ ('barcelona', [(13, 'rain'), (17, 'rain'), (18, 'clear'), (20, 'clear'), (18, 'cloud'), (17, 'rain'), (21, 'clear')]),
+}
+
+place_has_features = {
+ 6: ["HappyHour"]
+}
+HOLIDAYS = {
+ (1, 1): "NewYearsDay",
+ (5, 1): "TestDay", # test purpose
+ (25, 12): "Christmas",
+ (31, 12): "NewYearsEve"
+}
\ No newline at end of file
diff --git a/opendf/applications/smcalflow/dialog_stub_data/stub_data_5.py b/opendf/applications/smcalflow/dialog_stub_data/stub_data_5.py
new file mode 100644
index 0000000..f222363
--- /dev/null
+++ b/opendf/applications/smcalflow/dialog_stub_data/stub_data_5.py
@@ -0,0 +1,113 @@
+"""
+Holds the stub data (concerning the smcalflow application) to test the system.
+"""
+
+from collections import namedtuple
+from datetime import timedelta
+
+from opendf.defs import get_system_date
+
+CURRENT_RECIPIENT_ID = 1007
+CURRENT_RECIPIENT_LOCATION_ID = 7
+
+# not bothering with nicknames for now
+DBPerson = namedtuple(
+ 'DBPerson', ['fullName', 'firstName', 'lastName', 'id', 'phone_number', 'email_address',
+ 'manager_id', 'friends'])
+db_persons = [
+ DBPerson('John Doe', 'John', 'Doe', 1001, '41761231001', 'john.doe@opendf.com', 1006, []),
+ # friend of Adam (current user)
+ DBPerson('Jane Doe', 'Jane', 'Doe', 1002, '41761231002', 'jane.doe@opendf.com', 1003, []),
+ DBPerson('Jon Smith', 'Jon', 'Smith', 1003, '41761231003', 'jon.smith@opendf.com', 1004, []),
+ # friend of Adam (current user)
+ # DBPerson('John_Smith', 'John', 'Smith', 1003, '41761231004', 'john.smith@opendf.com', 1004, []), # friend of Adam (current user)
+ DBPerson('Jane Smith', 'Jane', 'Smith', 1004, '41761231004', 'jane.smith@opendf.com', 1004, []),