Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYNC develop to Design System Branch #2207

Merged
merged 20 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5fb64a2
FWF 3582 [Feature] Added search paramer and removed formName to searc…
shuhaib-aot Aug 14, 2024
9c3d87b
FWF 3582 [Feature] Changed FormName to search in query parameter in f…
shuhaib-aot Aug 14, 2024
7406902
Updating camunda and camundaKeycloak version
sumesh-aot Aug 14, 2024
949746a
Update KeycloakAuthenticationProvider.java
sumesh-aot Aug 15, 2024
33c550c
fix main route for view submision
abilpraju-aot Aug 20, 2024
ee5808f
Commenting out JWT Auth for working with Keycloak 25
sumesh-aot Aug 21, 2024
3bd30c5
Merge pull request #2195 from sumesh-aot/FWF-3599-camunda-kc-update
sumesh-aot Aug 21, 2024
9dc85d9
Reverting Camunda to 7.20.0 to avoid warning
sumesh-aot Aug 21, 2024
11485b1
Merge pull request #2205 from sumesh-aot/FWF-3599-camunda-kc-update
arun-s-aot Aug 22, 2024
771059a
Merge pull request #2202 from abilpraju-aot/bugfix/FWF-3612-submision…
arun-s-aot Aug 22, 2024
21d0713
Merge branch 'develop' of https://github.com/AOT-Technologies/forms-f…
shuhaib-aot Aug 22, 2024
9538f17
Merge pull request #2194 from shuhaib-aot/Feature/FWF-3582-add-search…
arun-s-aot Aug 22, 2024
1723004
updated keycloak version
abilpraju-aot Aug 22, 2024
dc203b1
Merge pull request #2206 from abilpraju-aot/keycloak-25.0.4
arun-s-aot Aug 22, 2024
d1016a9
FWF:3612 [Bugfix] Fixed Access denied issue
fahad-aot Aug 22, 2024
0cf018d
Syncing up changes from ee for IDM SPIs
sumesh-aot Aug 22, 2024
2bd71b4
FWF-3621: [Added] Added formio search endpoint to api utils
auslin-aot Aug 23, 2024
342d3b1
Merge pull request #2210 from auslin-aot/feature/FWF-3621-add-formio-…
arun-s-aot Aug 23, 2024
031a588
Merge pull request #2209 from sumesh-aot/idm-changes
arun-s-aot Aug 23, 2024
6f348e1
Merge pull request #2208 from fahad-aot/bugfix/FWF-3612-Access-denied…
arun-s-aot Aug 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions forms-flow-api-utils/src/formsflow_api_utils/utils/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class ApplicationSortingParameters: # pylint: disable=too-few-public-methods
Created = "created"
Name = "applicationName"
Status = "applicationStatus"
FormStatus = "status"
Modified = "modified"
FormName = "formName"
visibility= "visibility"
is_anonymous= "is_anonymous"


@unique
Expand Down
4 changes: 4 additions & 0 deletions forms-flow-api-utils/src/formsflow_api_utils/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def validate_sort_order_and_order_by(order_by: str, sort_order: str) -> bool:
ApplicationSortingParameters.Name,
ApplicationSortingParameters.Status,
ApplicationSortingParameters.Modified,
ApplicationSortingParameters.FormStatus,
ApplicationSortingParameters.FormName,
ApplicationSortingParameters.visibility,
DraftSortingParameters.Name,
ProcessSortingParameters.Name,
ProcessSortingParameters.Created,
Expand All @@ -73,6 +75,8 @@ def validate_sort_order_and_order_by(order_by: str, sort_order: str) -> bool:
else:
if order_by in [ApplicationSortingParameters.Name, DraftSortingParameters.Name]:
order_by = ApplicationSortingParameters.FormName
if order_by == ApplicationSortingParameters.visibility:
order_by = ApplicationSortingParameters.is_anonymous
order_by = camel_to_snake(order_by)
if sort_order not in ["asc", "desc"]:
sort_order = None
Expand Down
86 changes: 43 additions & 43 deletions forms-flow-api/src/formsflow_api/models/form_process_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from formsflow_api_utils.utils.enums import FormProcessMapperStatus
from formsflow_api_utils.utils.user_context import UserContext, user_context
from sqlalchemy import UniqueConstraint, and_, desc, func
from sqlalchemy import UniqueConstraint, and_, desc, func, or_
from sqlalchemy.dialects.postgresql import JSON
from sqlalchemy.sql.expression import text

Expand Down Expand Up @@ -182,6 +182,36 @@ def get_latest_form_mapper_ids(cls):
.all()
)

@classmethod
def add_sort_filter(cls, query, sort_by, sort_order):
"""Adding sortBy and sortOrder."""
order = []
if sort_by and sort_order:
for sort_by_att, sort_order_attr in zip(sort_by, sort_order):
name, value = validate_sort_order_and_order_by(
sort_order=sort_order_attr, order_by=sort_by_att
)
if name and value:
order.append(text(f"form_process_mapper.{name} {value}"))

query = query.order_by(*order)
return query

@classmethod
def add_search_filter(cls, query, search):
"""Adding search filter in query."""
if search:
filters = []
for term in search:
filters.append(
or_(
FormProcessMapper.form_name.ilike(f"%{term}%"),
FormProcessMapper.description.ilike(f"%{term}%"),
)
)
query = query.filter(or_(*filters))
return query

@classmethod
def find_all_forms(
cls,
Expand All @@ -192,19 +222,24 @@ def find_all_forms(
form_ids=None,
is_active=None,
form_type=None,
**filters,
search=None,
): # pylint: disable=too-many-arguments
"""Fetch all active and inactive forms which are not deleted."""
# Get latest row for each form_id group
filtered_form_query = cls.get_latest_form_mapper_ids()
filtered_form_ids = [
data.id for data in filtered_form_query if data.parent_form_id in form_ids
]
query = cls.filter_conditions(**filters)
query = query.filter(

query = cls.query.filter(
and_(FormProcessMapper.deleted.is_(False)),
FormProcessMapper.id.in_(filtered_form_ids),
)

query = cls.add_search_filter(query=query, search=search)

query = cls.add_sort_filter(query=query, sort_by=sort_by, sort_order=sort_order)

# form type is list of type to filter the form
if form_type:
query = query.filter(FormProcessMapper.form_type.in_(form_type))
Expand All @@ -214,9 +249,6 @@ def find_all_forms(
query = query.filter(FormProcessMapper.status == value)

query = cls.tenant_authorization(query=query)
sort_by, sort_order = validate_sort_order_and_order_by(sort_by, sort_order)
if sort_by and sort_order:
query = query.order_by(text(f"form_process_mapper.{sort_by} {sort_order}"))

total_count = query.count()
query = query.with_entities(
Expand All @@ -242,23 +274,21 @@ def find_all_active_by_formid(
limit=None,
sort_by=None,
sort_order=None,
search=None,
form_ids=None,
**filters,
): # pylint: disable=too-many-arguments
"""Fetch all active form process mappers by authorized forms."""
# Get latest row for each form_id group
filtered_form_query = cls.get_latest_form_mapper_ids()
filtered_form_ids = [
data.id for data in filtered_form_query if data.parent_form_id in form_ids
]
query = cls.filter_conditions(**filters)
query = query.filter(
query = cls.query.filter(
FormProcessMapper.id.in_(filtered_form_ids),
)
query = cls.add_search_filter(query=query, search=search)
query = cls.access_filter(query=query)
sort_by, sort_order = validate_sort_order_and_order_by(sort_by, sort_order)
if sort_by and sort_order:
query = query.order_by(text(f"form_process_mapper.{sort_by} {sort_order}"))
query = cls.add_sort_filter(sort_by=sort_by, sort_order=sort_order, query=query)

total_count = query.count()
query = query.with_entities(
Expand All @@ -273,36 +303,6 @@ def find_all_active_by_formid(
query = query.paginate(page=page_number, per_page=limit, error_out=False)
return query.items, total_count

@classmethod
def find_all_active(
cls,
page_number=None,
limit=None,
sort_by=None,
sort_order=None,
process_key=None,
**filters,
): # pylint: disable=too-many-arguments
"""Fetch all active form process mappers."""
query = cls.filter_conditions(**filters)
if process_key is not None:
query = query.filter(FormProcessMapper.process_key.in_(process_key))
query = cls.access_filter(query=query)
sort_by, sort_order = validate_sort_order_and_order_by(sort_by, sort_order)
if sort_by and sort_order:
query = query.order_by(text(f"form_process_mapper.{sort_by} {sort_order}"))

total_count = query.count()
query = query.with_entities(
cls.id,
cls.process_key,
cls.form_id,
cls.form_name,
)
limit = total_count if limit is None else limit
query = query.paginate(page=page_number, per_page=limit, error_out=False)
return query.items, total_count

@classmethod
def find_all_count(cls):
"""Fetch the total active form process mapper which are active."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ class FormResourceList(Resource):
"description": "Specify sorting order.",
"default": "desc",
},
"formName": {
"search": {
"in": "query",
"description": "Retrieve form list based on form name.",
"description": "Retrieve form list based on form name or description.",
"default": "",
},
}
Expand All @@ -271,27 +271,30 @@ class FormResourceList(Resource):
def get(): # pylint: disable=too-many-locals
"""Get form process mapper."""
dict_data = FormProcessMapperListRequestSchema().load(request.args) or {}
form_name: str = dict_data.get("form_name")
search: str = dict_data.get("search", "")
page_no: int = dict_data.get("page_no")
limit: int = dict_data.get("limit")
sort_by: str = dict_data.get("sort_by", "id")
sort_order: str = dict_data.get("sort_order", "desc")
sort_by: str = dict_data.get("sort_by", "")
sort_order: str = dict_data.get("sort_order", "")
form_type: str = dict_data.get("form_type", None)
is_active = dict_data.get("is_active", None)
active_forms = dict_data.get("active_forms", None)

sort_by = sort_by.split(",")
sort_order = sort_order.split(",")
if form_type:
form_type = form_type.split(",")
if form_name:
form_name: str = form_name.replace("%", r"\%").replace("_", r"\_")
if search:
search = search.replace("%", r"\%").replace("_", r"\_")
search = search.split(" ")

(
form_process_mapper_schema,
form_process_mapper_count,
) = FormProcessMapperService.get_all_forms(
page_number=page_no,
limit=limit,
form_name=form_name,
search=search if search else [],
sort_by=sort_by,
sort_order=sort_order,
form_type=form_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Meta: # pylint: disable=too-few-public-methods
class FormProcessMapperListRequestSchema(FormProcessMapperListReqSchema):
"""This class manages formprocessmapper list request schema."""

form_name = fields.Str(data_key="formName", required=False)
search = fields.Str(data_key="search", required=False)
sort_by = fields.Str(data_key="sortBy", required=False)
sort_order = fields.Str(data_key="sortOrder", required=False)
form_type = fields.Str(data_key="formType", required=False)
Expand Down
44 changes: 14 additions & 30 deletions forms-flow-api/src/formsflow_api/services/form_process_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class FormProcessMapperService:
def get_all_forms(
page_number: int,
limit: int,
form_name: str,
sort_by: str,
sort_order: str,
search: list,
sort_by: list,
sort_order: list,
form_type: str,
is_active,
is_designer: bool,
Expand Down Expand Up @@ -67,7 +67,7 @@ def get_all_forms(
mappers, get_all_mappers_count = list_form_mappers(
page_number=page_number,
limit=limit,
form_name=form_name,
search=search,
sort_by=sort_by,
sort_order=sort_order,
form_ids=authorized_form_ids,
Expand All @@ -79,30 +79,6 @@ def get_all_forms(
get_all_mappers_count,
)

@staticmethod
def get_all_mappers(
page_number: int,
limit: int,
form_name: str,
sort_by: str,
sort_order: str,
process_key: list = None,
): # pylint: disable=too-many-arguments
"""Get all form process mappers."""
mappers, get_all_mappers_count = FormProcessMapper.find_all_active(
page_number=page_number,
limit=limit,
form_name=form_name,
sort_by=sort_by,
sort_order=sort_order,
process_key=process_key,
)
mapper_schema = FormProcessMapperSchema()
return (
mapper_schema.dump(mappers, many=True),
get_all_mappers_count,
)

@staticmethod
def get_mapper_count(form_name=None):
"""Get form process mapper count."""
Expand Down Expand Up @@ -314,7 +290,9 @@ def _get_form( # pylint: disable=too-many-arguments
tenant_prefix = f"{tenant_key}-"
form_path = form_json.get("path", "")
form_name = form_json.get("name", "")
current_app.logger.info(f"Removing tenant key from path: {form_path} & name: {form_name}")
current_app.logger.info(
f"Removing tenant key from path: {form_path} & name: {form_name}"
)
if form_path.startswith(tenant_prefix):
form_json["path"] = form_path[len(tenant_prefix) :]

Expand Down Expand Up @@ -489,7 +467,13 @@ def export( # pylint:disable=too-many-locals

# Capture main form & workflow
forms.append(
self._get_form(mapper.form_name, "main", mapper.form_id, mapper.description, tenant_key)
self._get_form(
mapper.form_name,
"main",
mapper.form_id,
mapper.description,
tenant_key,
)
)
workflow = self._get_workflow(
mapper.process_key, mapper.process_name, "main", user
Expand Down
6 changes: 3 additions & 3 deletions forms-flow-api/tests/unit/api/test_form_process_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def test_form_process_mapper_paginated_sorted_list(
@pytest.mark.parametrize(
("pageNo", "limit", "filters"),
(
(1, 5, "formName=free"),
(1, 10, "formName=Free"),
(1, 20, "formName=privacy"),
(1, 5, "search=free"),
(1, 10, "search=Free"),
(1, 20, "search=privacy"),
),
)
def test_form_process_mapper_paginated_filtered_list(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
form_service = FormProcessMapperService()


def test_form_get_all_mappers(app, client, session):
"""Tests get_all_mappers handler when query params are None."""
rv = form_service.get_all_mappers(
page_number=None, limit=None, form_name=None, sort_by=None, sort_order=None
)
assert rv == ([], 0)


def test_get_form_mapper_count(app, client, session):
"""Tets the get_mapper_count method."""
rv = form_service.get_mapper_count()
Expand Down
6 changes: 3 additions & 3 deletions forms-flow-bpm/forms-flow-bpm-camunda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<failOnMissingWebXml>false</failOnMissingWebXml>

<!-- versions -->
<version.camundaKeycloak>7.20.0</version.camundaKeycloak>
<version.camundaKeycloak>7.21.5</version.camundaKeycloak>
<version.camunda>7.20.0</version.camunda><!-- 7.18.0 - 7.20.0 -->
<version.camundaConnect>1.5.4</version.camundaConnect><!-- 1.5.4 -->
<version.camundaMail>1.5.0</version.camundaMail><!-- 1.5.0 -->
Expand Down Expand Up @@ -183,7 +183,7 @@
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-rest-core</artifactId>
<version>7.20.0</version>
<version>${version.camunda}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -370,7 +370,7 @@
<dependency>
<groupId>org.camunda.bpm.extension</groupId>
<artifactId>camunda-platform-7-keycloak-jwt</artifactId>
<version>7.20.0</version>
<version>${version.camunda}</version>
</dependency>

<!-- Vault Starter -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private List<String> getKeys(OidcIdToken token, String nodeName) {
List<String> keys = new ArrayList<>();
if (token.getClaims().containsKey(nodeName)) {
Object claimValue = token.getClaim(nodeName);
if (claimValue instanceof JSONArray jsonArray) {
if (claimValue instanceof ArrayList jsonArray) {
for (Object array : jsonArray) {
String keyString = array.toString();
keys.add(StringUtils.contains(keyString, "/") ? StringUtils.substringAfter(keyString, "/") : keyString);
Expand Down
Loading
Loading