-
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.
- Loading branch information
Showing
32 changed files
with
934 additions
and
301 deletions.
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
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
130 changes: 0 additions & 130 deletions
130
src/main/java/callhub/connect/controllers/FileController.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
src/main/java/callhub/connect/data_access/FileDataAcessObject.java
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,78 @@ | ||
package callhub.connect.data_access; | ||
|
||
import callhub.connect.entities.FileDocument; | ||
import callhub.connect.entities.Session; | ||
import callhub.connect.use_case.file.FileDataAccessInterface; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Optional; | ||
|
||
@Service | ||
public class FileDataAcessObject implements FileDataAccessInterface { | ||
@Autowired | ||
private DocumentRepository documentRepository; | ||
|
||
@Autowired | ||
private SessionRepository sessionRepository; | ||
|
||
/** | ||
* Searches for and returns a FileDocument by its ID. | ||
* | ||
* @param id The ID of the FileDocument to be retrieved. | ||
* @return An Optional containing the FileDocument if found, or an empty Optional if not found. | ||
*/ | ||
@Override | ||
public Optional<FileDocument> findDocumentByID(String id) { | ||
return documentRepository.findById(id); | ||
} | ||
|
||
/** | ||
* Attempts to save a FileDocument to the document repository. | ||
* | ||
* This method tries to save the provided FileDocument object to the repository. | ||
* If successful, it returns an Optional containing the saved FileDocument. | ||
* If any exception occurs during the save process, it returns an empty Optional. | ||
* | ||
* @param file The FileDocument to be saved. | ||
* @return An Optional containing the saved FileDocument, or an empty Optional in case of failure. | ||
*/ | ||
@Override | ||
public Optional<FileDocument> uploadFile(FileDocument file) { | ||
try { | ||
return Optional.of(documentRepository.save(file)); | ||
} catch (Exception e) { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
/** | ||
* Checks if an active session exists with the given code. | ||
* | ||
* This method queries the session repository to determine whether there is an active session | ||
* matching the provided code. | ||
* | ||
* @param code The code of the session to be checked. | ||
* @return true if an active session with the given code exists, false otherwise. | ||
*/ | ||
@Override | ||
public boolean findSession(String code) { | ||
return sessionRepository.existsByCodeAndActive(code, true); | ||
} | ||
|
||
/** | ||
* Adds a document ID to an active session specified by its code. | ||
* | ||
* Retrieves the active session with the specified code and adds the provided document ID to it. | ||
* The updated session is then saved back to the repository. | ||
* | ||
* @param code The code of the active session to which the document ID will be added. | ||
* @param id The document ID to add to the session. | ||
*/ | ||
@Override | ||
public void addIDToSession(String code, String id) { | ||
Session currentSession = sessionRepository.getSessionsByActiveAndCode(true, code); | ||
currentSession.addDocument(id); | ||
sessionRepository.save(currentSession); | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
src/main/java/callhub/connect/data_access/LocalDataAccess.java
This file was deleted.
Oops, something went wrong.
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
25 changes: 0 additions & 25 deletions
25
src/main/java/callhub/connect/data_access/NetworkDataAccess.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.