Skip to content

Commit

Permalink
Merge branch 'main' into 39-feature-21-handling-change-task-details
Browse files Browse the repository at this point in the history
  • Loading branch information
SoumyadipSarker authored Aug 5, 2023
2 parents 0d6e8be + 51f376d commit dcf03bb
Show file tree
Hide file tree
Showing 32 changed files with 854 additions and 534 deletions.
5 changes: 5 additions & 0 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import c_interface_adapters.ProjectSelectionPresenter;
import d_frameworks_and_drivers.database_management.DatabaseInitializer.DBInitializer;
import d_frameworks_and_drivers.database_management.ProjectUUIDArray;
import javafx.application.Application;

import java.util.UUID;

public class Main {
public static void main(String[] args) {
System.out.println(ProjectUUIDArray.convertCsvToArrayList());
System.out.println("Main Above");
Application.launch(ProjectSelectionPresenter.class, args);
}
}
36 changes: 18 additions & 18 deletions src/main/java/a_enterprise_business_rules/entities/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.*;


/**
* A column within the productivity application.
*
Expand Down Expand Up @@ -180,13 +179,13 @@ public void moveTaskToPosition(Task taskToMove, int positionToMoveTo) throws NoS
int tasksNumber = this.tasks.size();

// Validity check
if (taskToMove == null){
if (taskToMove == null) {
throw new IllegalArgumentException("Task cannot be null.");
}

if (positionToMoveTo < 0||positionToMoveTo >= tasksNumber){
if (positionToMoveTo < 0 || positionToMoveTo >= tasksNumber) {
throw new IllegalArgumentException("Invalid positionToMoveTo index. " +
"It must be between 0 and " +(tasksNumber - 1) + " inclusive.");
"It must be between 0 and " + (tasksNumber - 1) + " inclusive.");
}

// Moving the column
Expand Down Expand Up @@ -259,12 +258,13 @@ public boolean equals(Object o) {
}

/**
* Searches an arraylist of columns and returns one that has the same ID as the given ID. Otherwise, returns null.
* Searches an List of columns and returns one that has the same ID as the given
* ID. Otherwise, returns null.
*
* @param columnID
* @param listOfColumns
*/
public static Column IDToColumn(UUID columnID, ArrayList<Column> listOfColumns) {
public static Column IDToColumn(UUID columnID, List<Column> listOfColumns) {
int i = 0;
boolean columnFound = false;
Column column = null;
Expand All @@ -278,17 +278,17 @@ public static Column IDToColumn(UUID columnID, ArrayList<Column> listOfColumns)
}
return column;
}
// testing IDToColumn helper function (Success!)
// public static void main(String[] args) {
// UUID id1 = UUID.randomUUID();
// UUID id2 = UUID.randomUUID();
// Column c1 = new Column("column 1", new ArrayList<Task>(), id1);
// Column c2 = new Column("column 2", new ArrayList<Task>(), id2);
// ArrayList<Column> listOfColumns = new ArrayList<Column>();
// listOfColumns.add(c1);
// listOfColumns.add(c2);
// Column found = Column.IDToColumn(id2, listOfColumns);
// System.out.println(c2.equals(found));
// }
// testing IDToColumn helper function (Success!)
// public static void main(String[] args) {
// UUID id1 = UUID.randomUUID();
// UUID id2 = UUID.randomUUID();
// Column c1 = new Column("column 1", new List<Task>(), id1);
// Column c2 = new Column("column 2", new List<Task>(), id2);
// List<Column> listOfColumns = new List<Column>();
// listOfColumns.add(c1);
// listOfColumns.add(c2);
// Column found = Column.IDToColumn(id2, listOfColumns);
// System.out.println(c2.equals(found));
// }

}
30 changes: 16 additions & 14 deletions src/main/java/a_enterprise_business_rules/entities/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Project {
/**
* The columns in the kanban board for this project.
*/
private ArrayList<Column> columns;
private List<Column> columns;

/**
* Creates a new project, based in the inputted values.
Expand All @@ -41,7 +41,7 @@ public class Project {
* @param description A description of the task.
* @param columns The columns of the project.
*/
public Project(String name, UUID ID, String description, ArrayList<Column> columns) {
public Project(String name, UUID ID, String description, List<Column> columns) {
this.name = name;
this.columns = columns;
this.description = description;
Expand Down Expand Up @@ -107,7 +107,7 @@ public void setDescription(String newDescription) {
*
* @return an <code>List<Column></code> of <Column>s.
*/
public ArrayList<Column> getColumns() {
public List<Column> getColumns() {
return this.columns;
}

Expand All @@ -116,7 +116,7 @@ public ArrayList<Column> getColumns() {
*
* @param newColumns The new columns for the project.
*/
public void setColumns(ArrayList<Column> newColumns) {
public void setColumns(List<Column> newColumns) {
this.columns = newColumns;
}

Expand Down Expand Up @@ -144,9 +144,11 @@ public void addColumnToPosition(Column newColumn, int position) {
*
* @param columnToMove The column that needs to be moved.
* @param positionToMoveTo The position/index to move the column to.
* @throws NoSuchElementException Throws exception when the specified column to
* remove is not in the columns of the project.
* @throws IllegalArgumentException Throws exception when the specified index is out
* @throws NoSuchElementException Throws exception when the specified column
* to
* remove is not in the columns of the project.
* @throws IllegalArgumentException Throws exception when the specified index is
* out
* of bounds.
*/
public void moveColumnToPosition(Column columnToMove, int positionToMoveTo)
Expand All @@ -157,13 +159,13 @@ public void moveColumnToPosition(Column columnToMove, int positionToMoveTo)
int columnsNumber = this.columns.size();

// Validity check
if (columnToMove == null){
if (columnToMove == null) {
throw new IllegalArgumentException("Column cannot be null.");
}

if (positionToMoveTo < 0||positionToMoveTo >= columnsNumber){
if (positionToMoveTo < 0 || positionToMoveTo >= columnsNumber) {
throw new IllegalArgumentException("Invalid positionToMoveTo index. " +
"It must be between 0 and " +(columnsNumber - 1) + " inclusive.");
"It must be between 0 and " + (columnsNumber - 1) + " inclusive.");
}

// Moving the column
Expand Down Expand Up @@ -197,10 +199,12 @@ public void removeColumn(Column columnToRemove) throws NoSuchElementException {
}

/**
* Removes a column with the specified ID from the list of columns in the current project.
* Removes a column with the specified ID from the list of columns in the
* current project.
*
* @param idOfColumnToRemove The ID of the column to be removed.
* @throws NoSuchElementException If no column with the given ID is found in the project.
* @throws NoSuchElementException If no column with the given ID is found in the
* project.
*/
public void removeColumn(UUID idOfColumnToRemove) throws NoSuchElementException {
for (Column column : columns) {
Expand All @@ -213,8 +217,6 @@ public void removeColumn(UUID idOfColumnToRemove) throws NoSuchElementException
"The column with ID " + idOfColumnToRemove + " is not in this project");
}



/**
* Swaps the order of two columns in the column.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,35 @@
import java.util.UUID;

public class CurrentProjectRepository {
private static final CurrentProjectRepository instance =
new CurrentProjectRepository();
/** The single instance of this singleton class */
private static final CurrentProjectRepository currentProjectRepository = new CurrentProjectRepository(null);

/** The current project that this repository is holding */
private ProjectModel currentProject;

public static CurrentProjectRepository getInstance() {
return instance;
/** Constructor for the singleton class */
public CurrentProjectRepository(ProjectModel currentProject) {
this.currentProject = currentProject;
}

private CurrentProjectRepository(){}
/** Gets the singleton instance of CurrentProjectRepository */
public static CurrentProjectRepository getCurrentprojectrepository() {
return currentProjectRepository;
}

/** Gets the project that the repository holds */
public ProjectModel getCurrentProject() {
return currentProject;
}

/** Sets the project that the repository holds */
public void setCurrentProject(ProjectModel project) {
currentProject = project;
}

/** Sets the project that the repository holds to a null reference. */
public void removeCurrentProject() {
currentProject = null;
this.setCurrentProject(null);
}

public void deleteProject(UUID projectID) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package b_application_business_rules.use_cases.project_selection_gateways;

import a_enterprise_business_rules.entities.*;
import b_application_business_rules.entity_models.*;

import java.util.UUID;
Expand All @@ -13,5 +12,4 @@ public interface IDBInsert {
void DBInsert(TaskModel taskModel);

void DBInsert(UUID uuid);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import b_application_business_rules.entity_models.*;

import java.util.*;

public interface IDBSearch {

ArrayList<String> DBColumnSearch(String id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,100 +1,43 @@
//package b_application_business_rules.use_cases.project_selection_use_cases;
//import a_enterprise_business_rules.entities.Project;
//import b_application_business_rules.boundaries.ProjectSelectionInputBoundary;
//import b_application_business_rules.boundaries.ProjectSelectionOutputBoundary;
//import b_application_business_rules.entity_models.ProjectModel;
//import b_application_business_rules.entity_models.ColumnModel;
//import java.util.List;
//import java.util.UUID;
//
//public class CreateProject implements ProjectSelectionInputBoundary {
// private final ProjectSelectionOutputBoundary outputBoundary;
//
// public CreateProject(ProjectSelectionOutputBoundary outputBoundary) {
// this.outputBoundary = outputBoundary;
// }
//
// @Override
// public void setCurrentProject(Project project) {
//
// }
//
// /**
// * @param project
// */
// @Override
// public void setCurrentProject(ProjectModel project) {
//
// }
//
// @Override
// public void createProject(String name, String description) {
//
// }
//
// /**
// *
// */
// @Override
// public void createProject() {
//
// }
//
//// @Override
//// public void createProject(ProjectModel projectModel){
//// try{
//// // Create the new Project entity
//// Project project = createProjectEntity(projectModel);
//// Project project1 = new Project(projectModel.getName(), projectModel.getID(), projectModel.getDescription(),
//// projectModel.getColumnModels());
////
//// // Notify via the output boundary if created successfully
//// outputBoundary.projectCreated(new ProjectModel(project.getName(), project.getID(), project.getDescription(),
//// projectModel.getColumnModels())); // ???
//// } catch (Exception e){
//// // Notify via the output boundary if cretion failed
//// outputBoundary.projectCreationFailed(e.getMessage());
//// }
//// }
//
// @Override
// public void projectDeletionFailed(String message) {
//
// }
//
// @Override
// public void projectDeleted(UUID projectID) {
//
// }
//
// @Override
// public void openProject(UUID currentProjectID) {
//
// }
//
// @Override
// public void renameProject(UUID projectUUID) {
//
// }
//
// @Override
// public void deleteProject(UUID projectUUID) {
//
// }
//
// // Validate projectModel data
// private void validateProjectModel(ProjectModel projectModel) {
// if (projectModel.getName() == null || projectModel.getName().isEmpty()){
// throw new IllegalArgumentException("Project name cannot be empty.");
// }
//
// // to be continued
// }
//
// // Create the Project entity from the ProjectModel (Project factory ?)
//// private Project createProjectEntity(ProjectModel projectModel) {
//// return new Project(projectModel.getName(), projectModel.getID(), projectModel.getDescription(),
//// projectModel.getColumnModels()); // ???
//// }
//
//}
package b_application_business_rules.use_cases.project_selection_use_cases;

import a_enterprise_business_rules.entities.Column;
import a_enterprise_business_rules.entities.Project;
import b_application_business_rules.entity_models.ProjectModel;
import b_application_business_rules.use_cases.project_selection_gateways.IDBInsert;
import d_frameworks_and_drivers.database_management.DBControllers.DBManagerInsertController;
import java.util.List;
import java.util.UUID;

public class CreateProject {
/**
* Empty constructor (would be autogenerated by Java if not included anyways)
*/
public CreateProject() {
}

/**
* Creates a project in the database based on the inputted <code>Project</code>.
*
* @param project The project to insert into the database.
*/
public void createProject(Project project) {
IDBInsert databaseInserter = new DBManagerInsertController();
ProjectModel projectModel = new ProjectModel(project);
databaseInserter.DBInsert(projectModel);
}

/**
* Creates a project in the database based on the inputted project's attributes.
*
* @param name The project's name.
* @param ID The project's UUID.
* @param description The project's description.
* @param columns The project's columns.
*/
public void createProject(String name, UUID ID, String description, List<Column> columns) {
IDBInsert databaseInserter = new DBManagerInsertController();
Project project = new Project(name, ID, description, columns);
ProjectModel projectModel = new ProjectModel(project);
databaseInserter.DBInsert(projectModel);
}
}
Loading

0 comments on commit dcf03bb

Please sign in to comment.