mbu-dev-shared-components 1.0.0__tar.gz → 1.1.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.
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/PKG-INFO +1 -1
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/getorganized/documents.py +62 -2
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/getorganized/objects.py +1 -1
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/utils/db_stored_procedure_executor.py +22 -16
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components.egg-info/PKG-INFO +1 -1
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components.egg-info/SOURCES.txt +2 -1
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/pyproject.toml +1 -1
- mbu_dev_shared_components-1.1.0/tests/test_database.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/LICENSE +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/README.md +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/database/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/database/constants.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/database/logging.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/database/utility.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/getorganized/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/getorganized/auth.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/getorganized/cases.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/getorganized/contacts.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/google/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/google/api/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/google/api/auth.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/google/workspace/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/google/workspace/alerts.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/msoffice365/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/msoffice365/excel/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/msoffice365/excel/excel_reader.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/msoffice365/sharepoint_api/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/msoffice365/sharepoint_api/files.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/os2forms/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/os2forms/documents.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/os2forms/forms.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/romexis/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/romexis/db_handler.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/sap/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/sap/create_invoice.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/solteqtand/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/solteqtand/app_handler.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/solteqtand/db_handler.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/solteqtand/helper_functions.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/utils/__init__.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/utils/fernet_encryptor.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/utils/file_handler.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components/utils/json_handler.py +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components.egg-info/dependency_links.txt +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components.egg-info/requires.txt +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/mbu_dev_shared_components.egg-info/top_level.txt +0 -0
- {mbu_dev_shared_components-1.0.0 → mbu_dev_shared_components-1.1.0}/setup.cfg +0 -0
|
@@ -123,8 +123,68 @@ def search_documents(search_term: str, api_endpoint: str, api_username: str, api
|
|
|
123
123
|
payload = {
|
|
124
124
|
"SearchPhrase": search_term,
|
|
125
125
|
"AdditionalColumns": [],
|
|
126
|
-
"ResultLimit":
|
|
127
|
-
"StartRow":
|
|
126
|
+
"ResultLimit": 500,
|
|
127
|
+
"StartRow": 0
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
headers = {'Content-Type': 'application/json'}
|
|
131
|
+
|
|
132
|
+
response = requests.request(method='POST', url=api_endpoint, headers=headers, json=payload, auth=get_ntlm_go_api_credentials(api_username, api_password), timeout=60)
|
|
133
|
+
|
|
134
|
+
return response
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def modern_search(page_index, search_term: str, start_date, end_date, only_items: bool, case_type_prefix: str, api_endpoint: str, api_username: str, api_password: str) -> requests.Response:
|
|
138
|
+
"""
|
|
139
|
+
Looks for documents in GetOrganized related to the specified search term
|
|
140
|
+
|
|
141
|
+
Parameters:
|
|
142
|
+
search_term (str): The phrase/term to be searched for in GetOrganized.
|
|
143
|
+
api_endpoint (str): GetOrganized API endpoint.
|
|
144
|
+
api_username (str): The API username for GetOrganized API.
|
|
145
|
+
api_password (str): The API password for GetOrganized API.
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
requests.Response: The response object from the API.
|
|
149
|
+
|
|
150
|
+
Raises:
|
|
151
|
+
requests.RequestException: If the HTTP request fails for any reason.
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
payload = {
|
|
155
|
+
"QueryPageIndex": page_index,
|
|
156
|
+
"PageSize": 500,
|
|
157
|
+
"QueryPhrase": f"{search_term}",
|
|
158
|
+
"QueryType": "DocumentLibrary",
|
|
159
|
+
"TrimToOpenedCases": False,
|
|
160
|
+
"ResultTypeName": "Dokumenter",
|
|
161
|
+
"SearchContentDefinitionEntryType": 0,
|
|
162
|
+
"AdditionalSelectColumns": [],
|
|
163
|
+
"ResultTypeListNameOrType": None,
|
|
164
|
+
"ResultTypeSearchOnlyItems": only_items,
|
|
165
|
+
"ResultTypeQueryFilter": None,
|
|
166
|
+
"CaseQueryFieldCollection": [
|
|
167
|
+
{
|
|
168
|
+
"DisplayName": "Sag oprettet",
|
|
169
|
+
"Guid": None,
|
|
170
|
+
"InternalName": "Created",
|
|
171
|
+
"Type": "SPFieldType.DateTime",
|
|
172
|
+
"Value": f"{start_date}T22:00:00.000Z",
|
|
173
|
+
"ToValue": f"{end_date}T22:00:00.000Z",
|
|
174
|
+
"IsTaxId": False,
|
|
175
|
+
"DecodeCrawledName": False,
|
|
176
|
+
"IsOrCondition": None,
|
|
177
|
+
"MappedName": "CCMCreatedCASEPROP"
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"QueryFieldCollection": [],
|
|
181
|
+
"CaseTypePrefixes": [
|
|
182
|
+
f"{case_type_prefix}"
|
|
183
|
+
],
|
|
184
|
+
"SortDirection1": 1,
|
|
185
|
+
"ResultViewSortOrder1": 2,
|
|
186
|
+
"ResultViewSortOrder2": 2,
|
|
187
|
+
"QueryScope": 0
|
|
128
188
|
}
|
|
129
189
|
|
|
130
190
|
headers = {'Content-Type': 'application/json'}
|
|
@@ -85,7 +85,7 @@ class CaseDataJson:
|
|
|
85
85
|
)
|
|
86
86
|
|
|
87
87
|
# Could be CaseTitle, CaseCategory, CaseProfile etc.
|
|
88
|
-
if
|
|
88
|
+
if field_properties:
|
|
89
89
|
for field_property_key, field_property_value in field_properties.items():
|
|
90
90
|
search_case_folder_data["FieldProperties"].append(
|
|
91
91
|
{
|
|
@@ -4,24 +4,24 @@ via the pyodbc library. The function connects to the database and executes the s
|
|
|
4
4
|
procedure with provided parameters, returning the success status and any error messages.
|
|
5
5
|
"""
|
|
6
6
|
import json
|
|
7
|
-
from typing import Dict, Any, Union
|
|
7
|
+
from typing import Dict, Any, Union, Tuple
|
|
8
8
|
from dateutil import parser
|
|
9
9
|
import pyodbc
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def execute_stored_procedure(connection_string: str, stored_procedure: str, params: Dict[str, Any]) -> Dict[str, Union[bool, str, Any]]:
|
|
12
|
+
def execute_stored_procedure(connection_string: str, stored_procedure: str, params: Dict[str, Tuple[type, Any]] | None = None) -> Dict[str, Union[bool, str, Any]]:
|
|
13
13
|
"""
|
|
14
14
|
Executes a stored procedure with the given parameters.
|
|
15
15
|
|
|
16
16
|
Args:
|
|
17
17
|
connection_string (str): The connection string to connect to the database.
|
|
18
18
|
stored_procedure (str): The name of the stored procedure to execute.
|
|
19
|
-
params (Dict[str, Any]): A dictionary of parameters to pass to the stored procedure.
|
|
19
|
+
params (Dict[str, Tuple[type, Any]], optional): A dictionary of parameters to pass to the stored procedure.
|
|
20
20
|
Each value should be a tuple of (type, actual_value).
|
|
21
21
|
|
|
22
22
|
Returns:
|
|
23
23
|
Dict[str, Union[bool, str, Any]]: A dictionary containing the success status, an error message (if any),
|
|
24
|
-
and additional data.
|
|
24
|
+
number of affected rows, and additional data.
|
|
25
25
|
"""
|
|
26
26
|
result = {
|
|
27
27
|
"success": False,
|
|
@@ -39,23 +39,29 @@ def execute_stored_procedure(connection_string: str, stored_procedure: str, para
|
|
|
39
39
|
try:
|
|
40
40
|
with pyodbc.connect(connection_string) as conn:
|
|
41
41
|
with conn.cursor() as cursor:
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if params:
|
|
43
|
+
param_placeholders = ', '.join([f"@{key} = ?" for key in params.keys()])
|
|
44
|
+
param_values = []
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
for key, value in params.items():
|
|
47
|
+
if isinstance(value, tuple) and len(value) == 2:
|
|
48
|
+
value_type, actual_value = value
|
|
49
|
+
if value_type in type_mapping:
|
|
50
|
+
param_values.append(type_mapping[value_type](actual_value))
|
|
51
|
+
else:
|
|
52
|
+
param_values.append(actual_value)
|
|
50
53
|
else:
|
|
51
|
-
|
|
52
|
-
else:
|
|
53
|
-
raise ValueError("Each parameter value must be a tuple of (type, actual_value).")
|
|
54
|
+
raise ValueError("Each parameter value must be a tuple of (type, actual_value).")
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
sql = f"EXEC {stored_procedure} {param_placeholders}"
|
|
57
|
+
rows_updated = cursor.execute(sql, tuple(param_values))
|
|
58
|
+
else:
|
|
59
|
+
sql = f"EXEC {stored_procedure}"
|
|
60
|
+
rows_updated = cursor.execute(sql)
|
|
61
|
+
print("Should be executed")
|
|
57
62
|
conn.commit()
|
|
58
63
|
result["success"] = True
|
|
64
|
+
result["rows_updated"] = rows_updated.rowcount
|
|
59
65
|
except pyodbc.Error as e:
|
|
60
66
|
result["error_message"] = f"Database error: {str(e)}"
|
|
61
67
|
except ValueError as e:
|
|
@@ -41,4 +41,5 @@ mbu_dev_shared_components/utils/__init__.py
|
|
|
41
41
|
mbu_dev_shared_components/utils/db_stored_procedure_executor.py
|
|
42
42
|
mbu_dev_shared_components/utils/fernet_encryptor.py
|
|
43
43
|
mbu_dev_shared_components/utils/file_handler.py
|
|
44
|
-
mbu_dev_shared_components/utils/json_handler.py
|
|
44
|
+
mbu_dev_shared_components/utils/json_handler.py
|
|
45
|
+
tests/test_database.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|