Handles interaction with database.
More...
#include <DatabaseHandler.h>
|
virtual void | connect (std::string ip, int port) |
| Establishes a connection to the database. More...
|
|
virtual bool | addProject (ProjectIn project) |
| Adds a project to database. More...
|
|
virtual void | addHashToProject (ProjectIn project, int index) |
| Adds a number of hashes to a project in the database, starting at some index. More...
|
|
virtual ProjectOut | searchForProject (ProjectID projectID, Version version) |
| Searches for a project in the database and returns it to the user if it exists. More...
|
|
virtual ProjectOut | prevProject (ProjectID projectID) |
| Retrieves the previous/latest version of the project present in the database. More...
|
|
virtual void | addMethod (MethodIn method, ProjectIn project, long long prevVersion, long long parserVersion, bool newProject) |
| Adds/updates a method to the tables methods and method_by_author. Takes in a method and a project and adds the method to the database with specific information of the project. More...
|
|
virtual std::vector< Hash > | updateUnchangedFiles (std::vector< Hash > hashes, std::vector< std::string > files, ProjectIn project, long long prevVersion) |
| Updates the methods in the previous version of the project that are part of an unchanged file. More...
|
|
virtual std::vector< MethodOut > | hashToMethods (std::string hash) |
| Retrieves all methods with a given hash. More...
|
|
virtual Author | idToAuthor (std::string id) |
| Retrieves an author given its authorID. More...
|
|
virtual std::vector< MethodID > | authorToMethods (std::string authorID) |
| Retrieves the methods created by an author given its authorID. More...
|
|
Handles interaction with database.
◆ addHashToProject()
void DatabaseHandler::addHashToProject |
( |
ProjectIn |
project, |
|
|
int |
index |
|
) |
| |
|
virtual |
Adds a number of hashes to a project in the database, starting at some index.
- Parameters
-
project | The project from which the hashes should be added to the database. |
index | The starting index of the hashes which should be added to the database. |
◆ addMethod()
void DatabaseHandler::addMethod |
( |
MethodIn |
method, |
|
|
ProjectIn |
project, |
|
|
long long |
prevVersion, |
|
|
long long |
parserVersion, |
|
|
bool |
newProject |
|
) |
| |
|
virtual |
Adds/updates a method to the tables methods and method_by_author. Takes in a method and a project and adds the method to the database with specific information of the project.
- Parameters
-
method | The method to be added/updated. |
project | The project in which the method is located. |
prevVersion | The previous version of the project. |
parserVersion | The version of the parser. |
newProject | Indication of the project being new or updated based on a previous version. |
◆ addProject()
bool DatabaseHandler::addProject |
( |
ProjectIn |
project | ) |
|
|
virtual |
Adds a project to database.
- Parameters
-
project | The project to be added to the database. |
- Returns
- A boolean value indicating if adding the project was successful.
◆ authorToMethods()
std::vector< MethodID > DatabaseHandler::authorToMethods |
( |
std::string |
authorID | ) |
|
|
virtual |
Retrieves the methods created by an author given its authorID.
- Parameters
-
authorID | The ID of the author to retrieve the methods for. |
- Returns
- A vector with the necessary information of the methods the author has worked on.
◆ connect()
void DatabaseHandler::connect |
( |
std::string |
ip, |
|
|
int |
port |
|
) |
| |
|
virtual |
Establishes a connection to the database.
- Parameters
-
ip | The ip in string format. |
port | The portnumber to connect to. |
◆ hashToMethods()
std::vector< MethodOut > DatabaseHandler::hashToMethods |
( |
std::string |
hash | ) |
|
|
virtual |
Retrieves all methods with a given hash.
- Parameters
-
hash | The hash to be checked. |
- Returns
- All methods with the inputted hash.
◆ idToAuthor()
Author DatabaseHandler::idToAuthor |
( |
std::string |
id | ) |
|
|
virtual |
Retrieves an author given its authorID.
- Parameters
-
id | A string with the ID to be checked. |
- Returns
- The author corresponding to the given ID.
◆ prevProject()
ProjectOut DatabaseHandler::prevProject |
( |
ProjectID |
projectID | ) |
|
|
virtual |
Retrieves the previous/latest version of the project present in the database.
- Parameters
-
projectID | The projectID of the project to be searched for. |
- Returns
- If present, returns the previous/latest version of a project with the same projectID. Else, sets the errno to ERANGE and returns an empty project.
◆ searchForProject()
ProjectOut DatabaseHandler::searchForProject |
( |
ProjectID |
projectID, |
|
|
Version |
version |
|
) |
| |
|
virtual |
Searches for a project in the database and returns it to the user if it exists.
- Parameters
-
projectID | The projectID of the project to be searched for. |
version | The version of the project to be searched for. |
- Returns
- Returns the project corresponding to the input, if it exists. If no entry can be found, simply returns an empty project and sets the errno to ERANGE.
◆ updateUnchangedFiles()
std::vector< Hash > DatabaseHandler::updateUnchangedFiles |
( |
std::vector< Hash > |
hashes, |
|
|
std::vector< std::string > |
files, |
|
|
ProjectIn |
project, |
|
|
long long |
prevVersion |
|
) |
| |
|
virtual |
Updates the methods in the previous version of the project that are part of an unchanged file.
- Parameters
-
hashes | A list of hashes to be checked. |
files | A list of files to be checked. |
project | The added project for the projectID and new version. |
prevVersion | The previous version of the project to check whether it is a correct result. |
- Returns
- A list of hashes that are updated.
The documentation for this class was generated from the following files:
- SearchSECODatabaseAPI/Database-API/DatabaseHandler.h
- SearchSECODatabaseAPI/Database-API/DatabaseHandler.cpp
- SearchSECODatabaseAPI/Database-API/DatabaseHandlerGet.cpp
- SearchSECODatabaseAPI/Database-API/DatabaseHandlerSet.cpp