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

Need ephemeral case base creation and retrieval functionality #20

Open
amardj opened this issue Nov 24, 2019 · 0 comments
Open

Need ephemeral case base creation and retrieval functionality #20

amardj opened this issue Nov 24, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@amardj
Copy link
Collaborator

amardj commented Nov 24, 2019

Ephemeral case bases are short-lived case bases, which are subsets of a main myCBR project case base.
They are primarily used for supporting various experiments on a CBR system.
e.g.

  • run-time creation of smaller case bases with the random selection of cases from the main case base.
  • run-time creation of seed-case bases
@amardj amardj added the enhancement New feature or request label Nov 24, 2019
amardj added a commit that referenced this issue Feb 3, 2020
# Details of this pull request
> **Primary focus of this pull request is in syntactic code refactoring**

## Issues Resolved in this Pull Request
** Resolved Issues: #20, #21, #23, #24, #26, #27, #28 ** 

## Standard and consistent REST API end-point naming
> This makes the code highly maintainable and consistent also prevents in accidental naming errors and inconsistencies.
> This helps to get rid of most common bad practice in coding known as "magic strings/numbers"

1) Adapted for consistent REST API path with naming conventions and String constants defined in ApiPathConstants.java
2) Adapted standard REST end-point operation naming by String constants defined in ApiOperationConstants.java
3) Removed the untidy redundant REST API response codes by creating annotations in the class ApiResponseAnnotations.java
 
## Package Restructuring
> The consistent and appropriate packages in java prove to be highly fruitful in the long run

1. Recommended best practice to keep main code and test code along with their respective resources in separate folders under the "src" folder. Main source codes in the "src/main" and the test source codes in "src/test". Similarly the respective resources in "src/main/resources" and "src/test/resources" folders.
2. The service package which is only used by the controller is moved under the no.ntnu.mycbr.rest.controller package ( "no.ntnu.mycbr.rest.controller.service")
3. The "no.ntnu.mycbr.rest.common" package is added to keep all the common constants.
4. The "no.ntnu.mycbr.rest.config" package is added to keep all the configuration related java classes.
5. All the java classes in the "no.ntnu.mycbr.rest package" are moved into their appropriate packages.
6. Many redundant java classes are removed from the codebase.
7. The "Case.java" and "Query.java" are used as helper classes for the controller and service classes, thus they are moved to the "no.ntnu.mycbr.rest.controller.helper" package.

## myCBR project file for Reference and Testing
1. Added a new myCBR project file (car_mycbr_project.prj). It is based on the used_cars_flat.prj file but with clean and consist names and similarity functions. Also, the attribute and similarity function errors are removed. The same copy of the file is kept under the main and test resources.
2. The cases with which the case base of car_mycbr_project.prj is populated is preserved in a .csv file under the main resources with the name "dataset_car_mycbr_project.csv"

## Controller and Service class Refactoring
> The respective controller and service classes are refactored not only to improve code readability, maintainability, and consistency but also to remove the code redundancy.
1. AttributeController.java is added to serve all the request pertaining to attribute CRUD and attribute similarity function operations.
2. EphemeralController.java is added to facilitate operations on ephemeral case base creation and retrievals on them.
3. The InstanceController.java is renamed to CaseController.java as to the external user of myCBR-rest application the term case is more appropriate.
4. Added the endpoint and implemented the SelfSimilarity computation for a given case base. This is in the class RetrievalController.java with the method name "getCaseBaseSelfSimilarity".
5. SelfSimilarity computation is also extended for the ephemeral case bases, but they are defined in the EphemeralController.java.
6. The java docs are provided for the newer implementations, but the legacy code will still require appropriate java docs.
7. The legacy code functionality and implementation logic and design are not addressed in this refactoring. 
8. Tried to adhere to an intuitive and consistent response body across the REST API end points.

## maven clean install - failure issues for JUnit test cases
> The test cases, which need to load a specific myCBR project file (<file_name>.prj) in the REST mocking environment, were failing in the CI build but they were passed in the IDE environment. This issue can also be reproduced by executing the command "mvn clean install" on any terminal or command prompt. The issue is fixed in this pull request. 

## Python Script for Users
- These scripts are under "**help**" folder.
- There is a python script (**mycbr-py-api.py**) which can be imported. Thus myCBR-REST API calls can be performed, without reimplementation.
- There is also a python notebook (**test-mycbr-py-api.ipynb**) file which presents how to use the above-mentioned python script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant