-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTaskObjectBuilder.py
198 lines (173 loc) · 8.89 KB
/
TaskObjectBuilder.py
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
import urllib3
from src.Tasks.PlacedTask import PlacedTask
from src.common import Utils
from src.Tasks.Task import Task
from src import TaskListHolder
from src.common.Database import Database
class TaskObjectBuilder:
# this will eventually go into app
Database.initialize()
# need to write methods for scaling the program up, (support multiple company's) needs to be general.
# key attached to buissness (set up the db to support it)
@staticmethod
def get_from_teamwork_scaled(actn, name, company_name, key):
http = urllib3.PoolManager()
company = company_name
key = key
action = actn
url = "https://{0}.teamwork.com/{1}".format(company, action)
headers = urllib3.util.make_headers(basic_auth=key + ":xxx")
request = http.request('GET', url, headers=headers)
data = request.data
dic = Utils.bytes_to_json(data)
tasks = dic[name]
return tasks
@staticmethod
def build_list(tasks):
for task in tasks:
_id = task["id"]
company_id = task["company-id"]
start_date = task["start-date"]
due_date = task["due-date"]
description = task["description"]
content = task["content"]
project_name = task["project-name"]
project_id = task["project-id"]
todo_list_name = task["todo-list-name"]
creator_lastname = task["creator-lastname"]
creator_firstname = task["creator-firstname"]
estimated_minutes = task["estimated-minutes"]
has_dependencies = task["has-dependencies"]
priority = task["priority"]
progress = task["progress"]
last_changed_on = task["last-changed-on"]
if 'responsible-party-id' in task.keys():
responsible_party_ids = task["responsible-party-ids"]
responsible_party_id = task["responsible-party-id"]
responsible_party_names = task["responsible-party-names"]
responsible_party_type = task["responsible-party-type"]
responsible_party_firstname = task["responsible-party-firstname"]
responsible_party_lastname = task["responsible-party-lastname"]
responsible_party_summary = task["responsible-party-summary"]
tsk = Task(_id, company_id, start_date, due_date, description, content, project_name, project_id, todo_list_name,
creator_lastname, creator_firstname, estimated_minutes, has_dependencies, priority, progress,
last_changed_on, responsible_party_ids, responsible_party_id, responsible_party_names,
responsible_party_type, responsible_party_firstname, responsible_party_lastname,
responsible_party_summary)
TaskListHolder.append_task(tsk)
continue
tsk = Task(_id, company_id, start_date, due_date, description, content, project_name, project_id, todo_list_name,
creator_lastname, creator_firstname, estimated_minutes, has_dependencies, priority, progress,
last_changed_on)
TaskListHolder.append_task(tsk)
# this is to be sent to a to the TaskListHolder
# that class is to hold the sorting methods and contain an append_task() method to add a task to an ArrayList<Task>
# append needs to be a static method.
# TaskListHolder.append_task(tsk)
@staticmethod
def build_completed_list(tasks):
for task in tasks:
_id = task["id"]
company_id = task["companyId"]
start_date = task["startDate"]
due_date = task["dueDate"]
description = task["description"]
content = task["content"]
project_name = task["projectName"]
project_id = task["projectId"]
todo_list_name = ""
creator_lastname = task["creatorLastName"]
creator_firstname = ""
estimated_minutes = ""
has_dependencies = ""
priority = ""
progress = ""
last_changed_on = ""
responsible_party_ids = ""
responsible_party_id = ""
responsible_party_names = ""
responsible_party_type = ""
responsible_party_firstname = ""
responsible_party_lastname = ""
responsible_party_summary = ""
tsk = Task(_id, company_id, start_date, due_date, description, content, project_name, project_id, todo_list_name,
creator_lastname, creator_firstname, estimated_minutes, has_dependencies, priority, progress,
last_changed_on, responsible_party_ids, responsible_party_id, responsible_party_names,
responsible_party_type, responsible_party_firstname, responsible_party_lastname,
responsible_party_summary)
TaskListHolder.append_task(tsk)
@staticmethod
def build_placed_task_list(tasks):
task_list = []
for task in tasks:
placed_task = TaskObjectBuilder.build_placed_task(task)
task_list.append(placed_task)
return task_list
# method to turn an external task into a placed task
@staticmethod
def build_placed_task(task, start, end, placed_by_id):
_id = task["_id"]
company_id = task["company_id"]
# variable to store the start time on the calender
calender_start_time = start
# variable to store the task end
calender_end_time = end
start_date = task["start_date"]
due_date = task["due_date"]
description = task["description"]
content = task["content"]
project_name = task["project_name"]
project_id = task["project_id"]
todo_list_name = task["todo_list_name"]
creator_lastname = task["creator_lastname"]
creator_firstname = task["creator_firstname"]
estimated_minutes = task["estimated_minutes"]
has_dependencies = task["has_dependencies"]
priority = task["priority"]
progress = task["progress"]
last_changed_on = task["last_changed_on"]
responsible_party_ids = task["responsible_party_ids"]
responsible_party_id = task["responsible_party_id"]
responsible_party_names = task["responsible_party_names"]
responsible_party_type = task["responsible_party_type"]
responsible_party_firstname = task["responsible_party_firstname"]
responsible_party_lastname = task["responsible_party_lastname"]
responsible_party_summary = task["responsible_party_summary"]
placed_by = placed_by_id
tsk = PlacedTask(_id, company_id, calender_start_time, calender_end_time, start_date, due_date, description,
content, project_name, project_id, todo_list_name, creator_lastname, creator_firstname,
estimated_minutes, has_dependencies, priority, progress, last_changed_on,
responsible_party_ids, responsible_party_id, responsible_party_names, responsible_party_type,
responsible_party_firstname, responsible_party_lastname, responsible_party_summary, placed_by)
return tsk
@staticmethod
def build_task(task):
_id = task["_id"]
company_id = task["company_id"]
start_date = task["start_date"]
due_date = task["due_date"]
description = task["description"]
content = task["content"]
project_name = task["project_name"]
project_id = task["project_id"]
todo_list_name = task["todo_list_name"]
creator_lastname = task["creator_lastname"]
creator_firstname = task["creator_firstname"]
estimated_minutes = task["estimated_minutes"]
has_dependencies = task["has_dependencies"]
priority = task["priority"]
progress = task["progress"]
last_changed_on = task["last_changed_on"]
responsible_party_ids = task["responsible_party_ids"]
responsible_party_id = task["responsible_party_id"]
responsible_party_names = task["responsible_party_names"]
responsible_party_type = task["responsible_party_type"]
responsible_party_firstname = task["responsible_party_firstname"]
responsible_party_lastname = task["responsible_party_lastname"]
responsible_party_summary = task["responsible_party_summary"]
tsk = Task(_id, company_id, start_date, due_date, description, content, project_name, project_id, todo_list_name,
creator_lastname, creator_firstname, estimated_minutes, has_dependencies, priority, progress,
last_changed_on, responsible_party_ids, responsible_party_id, responsible_party_names,
responsible_party_type, responsible_party_firstname, responsible_party_lastname,
responsible_party_summary)
return tsk