-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added adapter for handling of search results
- Loading branch information
1 parent
6ec8d44
commit 6ebb6c8
Showing
4 changed files
with
194 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
# Examples | ||
# Examples | ||
|
||
## Configuration File | ||
|
||
The configuration file must have the same structure as `examples\config.json`. | ||
|
||
## Adapter | ||
|
||
Each project must provide an `Adapter` class with the methods `handle_jira` and `handle_polarion` to pack the data from the search results into the output dictionary. | ||
The declaration, arguments and name of the methods must remain the same as in `examples\adapter\adapter.py`, otherwise the program will not work correctly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
|
||
"""Project-Specific Adapter Module""" | ||
|
||
# BSD 3-Clause License | ||
# | ||
# Copyright (c) 2024, NewTec GmbH | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, this | ||
# list of conditions and the following disclaimer. | ||
# | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICU5LAR PURPOSE ARE | ||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
################################################################################ | ||
# Imports | ||
################################################################################ | ||
|
||
from typing import Callable | ||
import logging | ||
|
||
################################################################################ | ||
# Variables | ||
################################################################################ | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
################################################################################ | ||
# Classes | ||
################################################################################ | ||
|
||
|
||
class Adapter: | ||
""" | ||
Adapter class for handling different search results. | ||
""" | ||
|
||
def handle_jira(self, | ||
search_results: dict, | ||
set_key_value_pair: Callable[[str, str], bool]) -> None: | ||
""" | ||
Handles the JIRA search results. | ||
Args: | ||
search_results: The search results from the JIRA API. | ||
set_key_value_pair: The callback function to set | ||
a key-value pair in the output dictionary. | ||
set_key_value_pair: | ||
Args: | ||
key: The key to set in the output dictionary. | ||
value: The value to set in the output dictionary. | ||
Returns: | ||
True if the key-value pair was set successfully, False otherwise. | ||
""" | ||
LOG.info("Handling JIRA search results...") | ||
LOG.info(type(search_results)) | ||
LOG.info(type(set_key_value_pair)) | ||
|
||
def handle_polarion(self, | ||
search_results: dict, | ||
set_key_value_pair: Callable[[str, str], bool]) -> None: | ||
""" | ||
Handles the Polarion search results. | ||
Args: | ||
search_results: The search results from the Polarion API. | ||
set_key_value_pair: The callback function to set | ||
a key-value pair in the output dictionary. | ||
set_key_value_pair: | ||
Args: | ||
key: The key to set in the output dictionary. | ||
value: The value to set in the output dictionary. | ||
Returns: | ||
True if the key-value pair was set successfully, False otherwise. | ||
""" | ||
LOG.info("Handling Polarion search results...") | ||
LOG.info(type(search_results)) | ||
LOG.info(type(set_key_value_pair)) | ||
|
||
################################################################################ | ||
# Functions | ||
################################################################################ | ||
|
||
################################################################################ | ||
# Main | ||
################################################################################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"adapter_path": "examples/adapter/adapter.py", | ||
"jira":{}, | ||
"polarion":{}, | ||
"superset":{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters