itk-dev-shared-components 1.3.0__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/PKG-INFO +1 -1
  2. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/kmd_nova/nova_cases.py +92 -6
  3. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/kmd_nova/nova_objects.py +20 -2
  4. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/kmd_nova/nova_tasks.py +23 -5
  5. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components.egg-info/PKG-INFO +1 -1
  6. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/pyproject.toml +1 -1
  7. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/LICENSE +0 -0
  8. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/README.md +0 -0
  9. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/__init__.py +0 -0
  10. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/graph/__init__.py +0 -0
  11. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/graph/authentication.py +0 -0
  12. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/graph/mail.py +0 -0
  13. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/kmd_nova/__init__.py +0 -0
  14. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/kmd_nova/authentication.py +0 -0
  15. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/kmd_nova/cpr.py +0 -0
  16. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/kmd_nova/nova_documents.py +0 -0
  17. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/kmd_nova/util.py +0 -0
  18. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/misc/__init__.py +0 -0
  19. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/misc/cpr_util.py +0 -0
  20. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/sap/__init__.py +0 -0
  21. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/sap/fmcacov.py +0 -0
  22. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/sap/gridview_util.py +0 -0
  23. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/sap/multi_session.py +0 -0
  24. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/sap/opret_kundekontakt.py +0 -0
  25. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/sap/sap_login.py +0 -0
  26. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/sap/sap_util.py +0 -0
  27. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components/sap/tree_util.py +0 -0
  28. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components.egg-info/SOURCES.txt +0 -0
  29. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components.egg-info/dependency_links.txt +0 -0
  30. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components.egg-info/requires.txt +0 -0
  31. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/itk_dev_shared_components.egg-info/top_level.txt +0 -0
  32. {itk_dev_shared_components-1.3.0 → itk_dev_shared_components-2.0.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: itk_dev_shared_components
3
- Version: 1.3.0
3
+ Version: 2.0.0
4
4
  Summary: Shared components to use in RPA projects
5
5
  Author-email: ITK Development <itk-rpa@mkb.aarhus.dk>
6
6
  Project-URL: Homepage, https://github.com/itk-dev-rpa/itk-dev-shared-components
@@ -8,7 +8,7 @@ import urllib.parse
8
8
  import requests
9
9
 
10
10
  from itk_dev_shared_components.kmd_nova.authentication import NovaAccess
11
- from itk_dev_shared_components.kmd_nova.nova_objects import NovaCase, CaseParty, JournalNote
11
+ from itk_dev_shared_components.kmd_nova.nova_objects import NovaCase, CaseParty, JournalNote, Caseworker, Department
12
12
  from itk_dev_shared_components.kmd_nova.util import datetime_from_iso_string
13
13
 
14
14
 
@@ -83,7 +83,30 @@ def get_cases(nova_access: NovaAccess, cpr: str = None, case_number: str = None,
83
83
  },
84
84
  "sensitivity": {
85
85
  "sensitivity": True
86
- }
86
+ },
87
+ "caseworker": {
88
+ "kspIdentity": {
89
+ "novaUserId": True,
90
+ "fullName": True,
91
+ "racfId": True
92
+ }
93
+ },
94
+ "responsibleDepartment": {
95
+ "losIdentity": {
96
+ "novaUnitId": True,
97
+ "administrativeUnitId": True,
98
+ "fullName": True,
99
+ "userKey": True
100
+ }
101
+ },
102
+ "securityUnit": {
103
+ "losIdentity": {
104
+ "novaUnitId": True,
105
+ "administrativeUnitId": True,
106
+ "fullName": True,
107
+ "userKey": True
108
+ }
109
+ },
87
110
  }
88
111
  }
89
112
 
@@ -98,6 +121,7 @@ def get_cases(nova_access: NovaAccess, cpr: str = None, case_number: str = None,
98
121
  # Convert json to NovaCase objects
99
122
  cases = []
100
123
  for case_dict in response.json()['cases']:
124
+ security_unit, responsible_department = _extract_departments(case_dict)
101
125
  case = NovaCase(
102
126
  uuid = case_dict['common']['uuid'],
103
127
  title = case_dict['caseAttributes']['title'],
@@ -110,7 +134,10 @@ def get_cases(nova_access: NovaAccess, cpr: str = None, case_number: str = None,
110
134
  note_count = case_dict['numberOfJournalNotes'],
111
135
  kle_number = case_dict['caseClassification']['kleNumber']['code'],
112
136
  proceeding_facet = case_dict['caseClassification']['proceedingFacet']['code'],
113
- sensitivity = case_dict["sensitivity"]["sensitivity"]
137
+ sensitivity = case_dict["sensitivity"]["sensitivity"],
138
+ caseworker = _extract_case_worker(case_dict),
139
+ security_unit=security_unit,
140
+ responsible_department=responsible_department
114
141
  )
115
142
 
116
143
  cases.append(case)
@@ -118,6 +145,49 @@ def get_cases(nova_access: NovaAccess, cpr: str = None, case_number: str = None,
118
145
  return cases
119
146
 
120
147
 
148
+ def _extract_departments(case_dict: dict) -> tuple[Department, Department]:
149
+ """Extract the departments from a HTTP request response.
150
+
151
+ Args:
152
+ case_dict: The dictionary describing the case.
153
+
154
+ Returns:
155
+ The security unit and the responsible department.
156
+ """
157
+ security_unit = Department(
158
+ id=case_dict['securityUnit']['losIdentity']['administrativeUnitId'],
159
+ name=case_dict['securityUnit']['losIdentity']['fullName'],
160
+ user_key=case_dict['securityUnit']['losIdentity']['userKey']
161
+ )
162
+
163
+ responsible_department = Department(
164
+ id=case_dict['responsibleDepartment']['losIdentity']['administrativeUnitId'],
165
+ name=case_dict['responsibleDepartment']['losIdentity']['fullName'],
166
+ user_key=case_dict['responsibleDepartment']['losIdentity']['userKey']
167
+ )
168
+
169
+ return security_unit, responsible_department
170
+
171
+
172
+ def _extract_case_worker(case_dict: dict) -> Caseworker | None:
173
+ """Extract the case worker from a HTTP request response.
174
+
175
+ Args:
176
+ case_dict: The dictionary describing the case.
177
+
178
+ Returns:
179
+ A case worker object describing the case worker if any.
180
+ """
181
+ if 'caseworker' in case_dict:
182
+ return Caseworker(
183
+ uuid = case_dict['caseworker']['kspIdentity']['novaUserId'],
184
+ name = case_dict['caseworker']['kspIdentity']['fullName'],
185
+ ident = case_dict['caseworker']['kspIdentity']['racfId']
186
+ )
187
+
188
+ return None
189
+
190
+
121
191
  def _extract_case_parties(case_dict: dict) -> list[CaseParty]:
122
192
  """Extract the case parties from a HTTP request response.
123
193
 
@@ -164,7 +234,7 @@ def _extract_journal_notes(case_dict: dict) -> list:
164
234
  return notes
165
235
 
166
236
 
167
- def add_case(case: NovaCase, nova_access: NovaAccess, security_unit_id: int = 818485, security_unit_name: str = "Borgerservice"):
237
+ def add_case(case: NovaCase, nova_access: NovaAccess):
168
238
  """Add a case to KMD Nova. The case will be created as 'Active'.
169
239
 
170
240
  Args:
@@ -208,8 +278,16 @@ def add_case(case: NovaCase, nova_access: NovaAccess, security_unit_id: int = 81
208
278
  ],
209
279
  "securityUnit": {
210
280
  "losIdentity": {
211
- "administrativeUnitId": security_unit_id,
212
- "fullName": security_unit_name,
281
+ "administrativeUnitId": case.security_unit.id,
282
+ "fullName": case.security_unit.name,
283
+ "userKey": case.security_unit.user_key
284
+ }
285
+ },
286
+ "responsibleDepartment": {
287
+ "losIdentity": {
288
+ "administrativeUnitId": case.responsible_department.id,
289
+ "fullName": case.responsible_department.name,
290
+ "userKey": case.responsible_department.user_key
213
291
  }
214
292
  },
215
293
  "SensitivityCtrlBy": "Bruger",
@@ -222,6 +300,14 @@ def add_case(case: NovaCase, nova_access: NovaAccess, security_unit_id: int = 81
222
300
  "AvailabilityCtrlBy": "Regler"
223
301
  }
224
302
 
303
+ if case.caseworker:
304
+ payload['caseworker'] = {
305
+ "kspIdentity": {
306
+ "racfId": case.caseworker.ident,
307
+ "fullName": case.caseworker.name
308
+ }
309
+ }
310
+
225
311
  headers = {'Content-Type': 'application/json', 'Authorization': f"Bearer {nova_access.get_bearer_token()}"}
226
312
 
227
313
  response = requests.post(url, params=params, headers=headers, json=payload, timeout=60)
@@ -8,6 +8,22 @@ from datetime import datetime
8
8
  # pylint: disable=too-many-instance-attributes
9
9
 
10
10
 
11
+ @dataclass(slots=True, kw_only=True)
12
+ class Department:
13
+ """A dataclass representing a department in a KMD Nova case."""
14
+ id: int
15
+ name: str
16
+ user_key: str
17
+
18
+
19
+ @dataclass(slots=True, kw_only=True)
20
+ class Caseworker:
21
+ """A dataclass representing a caseworker in a KMD Nova case."""
22
+ uuid: str
23
+ name: str
24
+ ident: str
25
+
26
+
11
27
  @dataclass(slots=True, kw_only=True)
12
28
  class CaseParty:
13
29
  """A dataclass representing a case party in a KMD Nova case."""
@@ -51,8 +67,7 @@ class Task:
51
67
  uuid: str
52
68
  title: str
53
69
  description: Optional[str] = None
54
- case_worker_ident: Optional[str] = None
55
- case_worker_uuid: str
70
+ caseworker: Caseworker
56
71
  status_code: Literal['N', 'S', 'F'] # Not Started, Started, Finished
57
72
  deadline: datetime
58
73
  created_date: Optional[datetime] = None
@@ -70,8 +85,11 @@ class NovaCase:
70
85
  active_code: Optional[str] = None
71
86
  progress_state: Literal["Opstaaet", "Oplyst", "Afgjort", "Bestilt", "Udfoert", "Afsluttet"]
72
87
  case_parties: list[CaseParty]
88
+ caseworker: Optional[Caseworker] = None
73
89
  document_count: Optional[int] = 0
74
90
  note_count: Optional[int] = 0
75
91
  kle_number: str
76
92
  proceeding_facet: str
77
93
  sensitivity: Literal["Fortrolige", "IkkeFortrolige", "SærligFølsomme", "Følsomme"]
94
+ responsible_department: Department
95
+ security_unit: Department
@@ -6,7 +6,7 @@ import urllib.parse
6
6
  import requests
7
7
 
8
8
  from itk_dev_shared_components.kmd_nova.authentication import NovaAccess
9
- from itk_dev_shared_components.kmd_nova.nova_objects import Task
9
+ from itk_dev_shared_components.kmd_nova.nova_objects import Task, Caseworker
10
10
  from itk_dev_shared_components.kmd_nova.util import datetime_from_iso_string, datetime_to_iso_string
11
11
 
12
12
 
@@ -35,7 +35,7 @@ def attach_task_to_case(case_uuid: str, task: Task, nova_access: NovaAccess) ->
35
35
  "caseUuid": case_uuid,
36
36
  "title": task.title,
37
37
  "description": task.description, # Optional
38
- "caseworkerPersonId": task.case_worker_uuid, # Optional
38
+ "caseworkerPersonId": task.caseworker.uuid, # Optional
39
39
  "statusCode": task.status_code,
40
40
  "deadline": datetime_to_iso_string(task.deadline),
41
41
  "startDate": datetime_to_iso_string(task.started_date), # Optional
@@ -89,8 +89,7 @@ def get_tasks(case_uuid: str, nova_access: NovaAccess, limit: int = 100) -> list
89
89
  uuid = task_dict['taskUuid'],
90
90
  title = task_dict['taskTitle'],
91
91
  description = task_dict.get('taskDescription'),
92
- case_worker_ident = task_dict['caseWorker']['ident'],
93
- case_worker_uuid = task_dict['caseWorker']['id'],
92
+ caseworker = _extract_caseworker(task_dict),
94
93
  status_code = task_dict['taskStatusCode'],
95
94
  deadline = datetime_from_iso_string(task_dict.get('taskDeadline')),
96
95
  created_date = datetime_from_iso_string(task_dict.get('taskCreateDate')),
@@ -102,6 +101,25 @@ def get_tasks(case_uuid: str, nova_access: NovaAccess, limit: int = 100) -> list
102
101
  return tasks
103
102
 
104
103
 
104
+ def _extract_caseworker(task_dict: dict) -> Caseworker | None:
105
+ """Extract the case worker from a HTTP request response.
106
+
107
+ Args:
108
+ case_dict: The dictionary describing the task.
109
+
110
+ Returns:
111
+ A case worker object describing the case worker if any.
112
+ """
113
+ if 'caseWorker' in task_dict:
114
+ return Caseworker(
115
+ uuid = task_dict['caseWorker']['id'],
116
+ ident = task_dict['caseWorker']['ident'],
117
+ name = task_dict['caseWorker']['name']
118
+ )
119
+
120
+ return None
121
+
122
+
105
123
  def update_task(task: Task, case_uuid: str, nova_access: NovaAccess):
106
124
  """Update a task that already exists in KMD Nova with new
107
125
  information.
@@ -125,7 +143,7 @@ def update_task(task: Task, case_uuid: str, nova_access: NovaAccess):
125
143
  "caseUuid": case_uuid,
126
144
  "title": task.title,
127
145
  "description": task.description,
128
- "caseworkerPersonId": task.case_worker_uuid,
146
+ "caseworkerPersonId": task.caseworker.uuid,
129
147
  "statusCode": task.status_code,
130
148
  "deadline": datetime_to_iso_string(task.deadline),
131
149
  "startDate": datetime_to_iso_string(task.started_date),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: itk_dev_shared_components
3
- Version: 1.3.0
3
+ Version: 2.0.0
4
4
  Summary: Shared components to use in RPA projects
5
5
  Author-email: ITK Development <itk-rpa@mkb.aarhus.dk>
6
6
  Project-URL: Homepage, https://github.com/itk-dev-rpa/itk-dev-shared-components
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "itk_dev_shared_components"
7
- version = "1.3.0"
7
+ version = "2.0.0"
8
8
  authors = [
9
9
  { name="ITK Development", email="itk-rpa@mkb.aarhus.dk" },
10
10
  ]