Skip to content

Commit

Permalink
Merge pull request #55 from CSC207-2023Y-UofT/add_and_delete_new_task
Browse files Browse the repository at this point in the history
Add and delete new task
  • Loading branch information
alexolowo authored Aug 4, 2023
2 parents c211ef8 + bb6425a commit 2c2e2a5
Show file tree
Hide file tree
Showing 20 changed files with 670 additions and 451 deletions.
40 changes: 34 additions & 6 deletions src/main/java/a_enterprise_business_rules/entities/Column.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package a_enterprise_business_rules.entities;

import java.util.List;
import java.util.Collections;

import java.util.UUID;

import java.util.NoSuchElementException;
import java.util.*;


/**
Expand Down Expand Up @@ -263,4 +258,37 @@ public boolean equals(Object o) {
return allAttributesAreEqual;
}

/**
* Searches an arraylist 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) {
int i = 0;
boolean columnFound = false;
Column column = null;
// loop until the right column is found
while (listOfColumns.size() > i && !columnFound) {
if (columnID.equals(listOfColumns.get(i).getID())) {
columnFound = true;
column = listOfColumns.get(i);
}
i++;
}
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));
// }

}
27 changes: 10 additions & 17 deletions src/main/java/a_enterprise_business_rules/entities/Project.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@

package a_enterprise_business_rules.entities;

import b_application_business_rules.entity_models.ColumnModel;

import java.util.List;
import java.util.Collections;

import java.util.UUID;

import java.util.NoSuchElementException;
import java.util.*;

/**
* A project within the productivity application.
Expand Down Expand Up @@ -38,7 +31,7 @@ public class Project {
/**
* The columns in the kanban board for this project.
*/
private List<ColumnModel> columns;
private ArrayList<Column> columns;

/**
* Creates a new project, based in the inputted values.
Expand All @@ -48,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, List<ColumnModel> columns) {
public Project(String name, UUID ID, String description, ArrayList<Column> columns) {
this.name = name;
this.columns = columns;
this.description = description;
Expand Down Expand Up @@ -114,7 +107,7 @@ public void setDescription(String newDescription) {
*
* @return an <code>List<Column></code> of <Column>s.
*/
public List<ColumnModel> getColumns() {
public ArrayList<Column> getColumns() {
return this.columns;
}

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

Expand All @@ -132,7 +125,7 @@ public void setColumns(List<ColumnModel> newColumns) {
*
* @param newColumn The column to add.
*/
public void addColumn(ColumnModel newColumn) {
public void addColumn(Column newColumn) {
this.columns.add(newColumn);
}

Expand All @@ -142,7 +135,7 @@ public void addColumn(ColumnModel newColumn) {
* @param newColumn The column to add to the project.
* @param position The position/index to add the column at.
*/
public void addColumnToPosition(ColumnModel newColumn, int position) {
public void addColumnToPosition(Column newColumn, int position) {
this.columns.add(position, newColumn);
}

Expand All @@ -156,7 +149,7 @@ public void addColumnToPosition(ColumnModel newColumn, int position) {
* @throws IllegalArgumentException Throws exception when the specified index is out
* of bounds.
*/
public void moveColumnToPosition(ColumnModel columnToMove, int positionToMoveTo)
public void moveColumnToPosition(Column columnToMove, int positionToMoveTo)
throws NoSuchElementException, IllegalArgumentException {
// The moving of the columns is done by removing the object from the List
// and then adding it back at the indicated index
Expand Down Expand Up @@ -191,7 +184,7 @@ public void moveColumnToPosition(ColumnModel columnToMove, int positionToMoveTo)
* @throws NoSuchElementException Throws exception when the specified column to
* remove is not in the project.
*/
public void removeColumn(ColumnModel columnToRemove) throws NoSuchElementException {
public void removeColumn(Column columnToRemove) throws NoSuchElementException {
if (!this.columns.remove(columnToRemove)) {
// the java.util.List.remove method returns a bool,
// indicating whether the object was removed or not.
Expand All @@ -210,7 +203,7 @@ public void removeColumn(ColumnModel columnToRemove) throws NoSuchElementExcepti
* @throws NoSuchElementException If no column with the given ID is found in the project.
*/
public void removeColumn(UUID idOfColumnToRemove) throws NoSuchElementException {
for (ColumnModel column : columns) {
for (Column column : columns) {
if (column.getID().equals(idOfColumnToRemove)) {
columns.remove(column);
return;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/a_enterprise_business_rules/entities/Task.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package a_enterprise_business_rules.entities;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.UUID;

/**
Expand Down Expand Up @@ -198,4 +199,18 @@ public boolean equals(Object o) {
return allAttributesAreEqual;
}

public static Task IDToTask(UUID taskID, ArrayList<Task> listOfTasks) {
int i = 0;
boolean taskFound = false;
Task task = null;
// loop until the right task is found
while (listOfTasks.size() > i && !taskFound) {
if (taskID.equals(listOfTasks.get(i).getID())) {
taskFound = true;
task = listOfTasks.get(i);
}
i++;
}
return task;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ default void updateTaskName(UUID taskID, TaskModel updatedTask) {

}


default void addNewTask(TaskModel newTask) {

}

default void updateTaskDetail(UUID taskID, TaskModel updatedTask) {

}

default void deleteTask(UUID taskID, TaskModel deletedTask) {
default void removeTask(UUID taskID, TaskModel deletedTask) {

}

Expand All @@ -30,5 +35,4 @@ default void updateColumnName(UUID columnID, ColumnModel updatedColumn) {
default void deleteColumn(UUID columnID, ColumnModel deletedColumn) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void addNewTask(UUID idOfColumn, String taskName, String taskDescription,

void renameColumn(UUID columnBoxId);

void deleteTask(TaskModel task, UUID TaskUIid);
void deleteTask(TaskModel task, UUID TaskUIid, UUID ColumnID);

void changeTaskDetails(TaskModel task, UUID TaskUIid);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package b_application_business_rules.entity_models;

import a_enterprise_business_rules.entities.Column;
import a_enterprise_business_rules.entities.Project;
import b_application_business_rules.use_cases.project_viewing_and_modification_use_cases.AddColumn;

import java.util.*;

Expand Down Expand Up @@ -58,10 +60,10 @@ public ProjectModel(Project project) {
this.name = project.getName();

// Converting the List of Column objects to a List of ColumnModel objects
List<ColumnModel> columns = project.getColumns(); // Get the columns
List<Column> columns = project.getColumns(); // Get the columns
// Converts Columns to ColumnModels and puts it in the columnModels attribute
for (ColumnModel cols : columns) {
this.addColumnModel(cols);
for (Column col : columns) {
this.addColumnModel(new ColumnModel(col));
}

this.description = project.getDescription();
Expand Down Expand Up @@ -261,12 +263,15 @@ public void swapColumnModelOrder(ColumnModel col1, ColumnModel col2) {
* @return a Project Entity.
*/
public Project getProjectEntity() {
List<ColumnModel> columnEntities = new ArrayList<>();
ArrayList<Column> columnEntities = new ArrayList<>();
for (ColumnModel columnModel: columnModels) {
columnEntities.add(columnModel);
columnEntities.add(AddColumn.createColumnEntity(columnModel));
}

return new Project(name, ID, description, columnEntities);

}



}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* A Column factory to create ColumnModels,
* Each ColumnModel has a name, list of TaskModels and ID
*/
public class ColumnFactory {
public class ColumnModelFactory {

/**
* Creates a ColumnModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package b_application_business_rules.factories;

import a_enterprise_business_rules.entities.*;

import b_application_business_rules.entity_models.ColumnModel;
import b_application_business_rules.entity_models.ProjectModel;

Expand All @@ -11,7 +9,7 @@
* A Project factory to create ProjectModels.
* Each ProjectModel has a name, ID, description and a list of ColumnModels
*/
public class ProjectFactory {
public class ProjectModelFactory {

/**
* Creates a ProjectModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@


import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

/**
* A Task factory to create TaskModels,
* Each TaskModel has a name, ID, description, completion status and date
*/
public class TaskFactory {
public class TaskModelFactory {

/**
* Creates a TaskModel
Expand Down
Loading

0 comments on commit 2c2e2a5

Please sign in to comment.