Skip to content

Commit

Permalink
documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-kan committed Aug 10, 2023
1 parent d806111 commit 1169d60
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public Map<String, String> getStringToStringMap(int keyColumn, int valueColumn){
/**
* Returns a Mapping from the string of key column field to the corresponding record
* @param keyColumn index of csv key column with string values only
* @param valueColumn index of csv value column
* @return Mapping from the string of key column field to the corresponding record
*/
public Map<String, CSVRecord> getStringToRecordMap(int keyColumn){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ private void openResources() throws IOException {
}

/**
* Searches for and returns csv record corresponding to field value given field/column index
* Searches for and returns csv record corresponding to field value given column header string
*
* @param fieldIndex
* @param fieldValue
* @param fieldIndex field where to do the search
* @param fieldValue search keys list
* @return csv record
*/
public CSVRecord getRecord(int fieldIndex, String fieldValue) throws IOException {
// Try with resource: create FileWriter, CSVParser object as resources - closes automatically
Expand All @@ -66,8 +67,9 @@ public CSVRecord getRecord(int fieldIndex, String fieldValue) throws IOException
/**
* Searches for and returns csv record corresponding to field value given column header string
*
* @param fieldIndex
* @param fieldValue
* @param keyHeader field where to do the search
* @param fieldValue search keys list
* @return csv record
*/
public CSVRecord getRecord(String keyHeader, String fieldValue) throws IOException {
// Try with resource: create FileWriter, CSVParser object as resources - closes automatically
Expand All @@ -89,10 +91,10 @@ public CSVRecord getRecord(String keyHeader, String fieldValue) throws IOExcepti
}

/**
*
* @param fieldIndex
* @param searchKeys
* @return
* Returns a list of csv records given field where to do the search and search keys list.
* @param fieldIndex field where to do the search
* @param searchKeys search keys list
* @return list of csv records
*/
public List<CSVRecord> getRecordsList(int fieldIndex, List<String> searchKeys){
List<CSVRecord> output = new ArrayList<>();
Expand All @@ -117,13 +119,34 @@ public List<CSVRecord> getRecordsList(int fieldIndex, List<String> searchKeys){
}
}








/**
* Returns a list of csv records given field where to do the search and search keys list.
* @param field field where to do the search
* @param searchKeys search keys list
* @return list of csv records
*/
public List<CSVRecord> getRecordsList(String field, List<String> searchKeys){
List<CSVRecord> output = new ArrayList<>();
// Try with resource: create FileWriter, CSVParser object as resources - closes automatically
try (FileReader fileReader = new FileReader(csvFile);
CSVMapper csvMapper = new CSVMapper(csvFile.getPath());
CSVParser csvParser = new CSVParser(fileReader, CSVFormat.DEFAULT.withHeader().withNullString(""))) {
// first, generate map of from column with search keys to records
Map<String,CSVRecord> strRecordMap = csvMapper.getStringToRecordMap(field);
// Generate a list of values from the map using searched keys
for (String key : searchKeys) {
CSVRecord record = strRecordMap.get(key);
if (record != null) {
output.add(record);
}
}
return output;
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

/**
* Close the CSVParser when the CSVSearcher is no longer needed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class DBManagerInsertController implements IDBInsert {
* Adds a project record with ProjectID, Name, Description and list of column IDs
* into the Database
*
* @param projectModel
* @param projectModel project model entity to be inserted
*/
public void DBInsert(ProjectModel projectModel) {

Expand Down Expand Up @@ -65,7 +65,7 @@ public void DBInsert(ProjectModel projectModel) {
* Adds a column record with fields "ColumnID","Name",
* and "Task ID's" into the Database
*
* @param columnModel
* @param columnModel column model entity to be inserted
*/
public void DBInsert(ColumnModel columnModel) {
// Try with resources: CSVWriter
Expand Down Expand Up @@ -141,7 +141,7 @@ public void DBInsert(TaskModel taskModel, UUID parentColumn) {

/**
* Adds a record of unique ID into the Database
* @param uuid
* @param uuid uuuid to be inserted
*/
public void DBInsert(UUID uuid) {
// Try with resources: CSVWriter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

public class DBManagerRemoveController implements IDBRemove {
/**
*
* @param projectModel
*/
public void DBRemove(ProjectModel projectModel, UUID uuid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ public ArrayList<String> DBColumnSearch(String id) {
}

/**
* @param id
* @return
* Searches project.csv for the entry with the UUID matching the id parameter
* then reads that line and converts it to an arraylist, with first element containing UUID,
* second element containing name and third - description, forth - containing list of column UUIDs
* * @param id project UUID ID as string
* @return arraylist of strings with project values from database
*/
public ArrayList<String> DBProjectSearch(String id) {
ArrayList<String> projectInfo = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ public List<ProjectModel> IDstoProjectModelList() {
}

/**
* @param projectUUID
* @return
* Returns a project model given its UUID ID.
* @param projectUUID UUID ID
* @return a project model
*/
public ProjectModel IDsToProjectModel(UUID projectUUID) {
ArrayList<String> DbEntry = searchController.DBProjectSearch(projectUUID.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
public class IDListsToModelList implements IDbIdToModelList {
DBManagerSearchController dbManagerSearchController = new DBManagerSearchController();
/**
* @param IDlist
* @return
* Returns a list of column entity models given a list of UUID IDs as strings for the columns.
* @param IDlist a list of UUID IDs as strings for the columns
* @return a list of column entity models
*/
public List<ColumnModel> IdToColumnModelList(List<String> IDlist) {
IDlist = List.of(IDlist.get(0).split(","));
Expand All @@ -38,8 +39,9 @@ public List<ColumnModel> IdToColumnModelList(List<String> IDlist) {
}

/**
* @param IDlist
* @return
* Returns a list of task entity models given a list of UUID IDs as strings for the tasks.
* @param IDlist a list of UUID IDs as strings for the tasks
* @return a list of task entity models
*/
public List<TaskModel> IdToTaskModelList(List<String> IDlist) {
IDlist = List.of(IDlist.get(0).split(","));
Expand All @@ -58,8 +60,9 @@ public List<TaskModel> IdToTaskModelList(List<String> IDlist) {
}

/**
* @param IDlist
* @return
* Returns a list of project entity models given a list of UUID IDs as strings for the projects.
* @param IDlist a list of UUID IDs as strings for the projects
* @return a list of project entity models
*/
public List<ProjectModel> IdToProjectModelList(List<String> IDlist) {
IDlist = List.of(IDlist.get(0).split(","));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
import java.io.File;
import java.io.FileWriter;


public class ColumnDBInitializer {
String[] ColumnHeaders = {"ColumnID", "Name", "Task ID's", "ProjectID"};

/**
* Initializes column csv file for database with the above headers.
*/
public ColumnDBInitializer() {
// create CSVWriter object filewriter object as parameter
File file = new File("src/main/java/d_frameworks_and_drivers/database_management/DatabaseFiles/Columns/Columns.csv");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

public class DBInitializer {
String [] DBNames = {"Projects", "Columns", "Tasks"};

CSVWriter writer;
public DBInitializer(){
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
public class ProjectDBInitializer {
String [] ProjectHeaders = {"ProjectID", "Name", "Description", "Column ID's"};

/**
* Initializes project csv file for database with the above headers.
*/
public ProjectDBInitializer() {
// create CSVWriter object filewriter object as parameter
File file = new File("src/main/java/d_frameworks_and_drivers/database_management/DatabaseFiles/Projects/Projects.csv");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
public class TaskDBInitializer {
String[] TaskHeaders = {"TaskID", "Name", "Description", "Completion Status", "Due Date", "ColumnID"};

/**
* Initializes tasks csv file for database with the above headers.
*/
public TaskDBInitializer() {
// create CSVWriter object filewriter object as parameter
File file = new File("src/main/java/d_frameworks_and_drivers/database_management/DatabaseFiles/Tasks/Tasks.csv");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
public class UniqueIDsInitializer {
String [] IdsDbHeaders = {"UUID", "State"};

/**
* Initializes UUID csv file for database with the above headers.
*/
public UniqueIDsInitializer() {
// create CSVWriter object filewriter object as parameter
File file = new File("src/main/java/d_frameworks_and_drivers/database_management/DatabaseFiles/UniqueIDs/UniqueIDs.csv");
Expand Down

0 comments on commit 1169d60

Please sign in to comment.