-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from jasonchristopher21/branch-fix-field-model
Integrate Attribute with Person, Task and Group
- Loading branch information
Showing
46 changed files
with
1,412 additions
and
365 deletions.
There are no files selected for viewing
57 changes: 0 additions & 57 deletions
57
src/main/java/seedu/address/logic/commands/AddFieldCommand.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
51 changes: 0 additions & 51 deletions
51
src/main/java/seedu/address/logic/commands/RemoveFieldCommand.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
src/main/java/seedu/address/logic/commands/attributes/AddAttributeCommand.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,39 @@ | ||
package seedu.address.logic.commands.attributes; | ||
|
||
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; | ||
|
||
import seedu.address.logic.commands.Command; | ||
|
||
/** | ||
* Adds an attribute to a person. | ||
*/ | ||
public abstract class AddAttributeCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "addfield"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a custom field to the address book. " | ||
+ "Parameters: CUSTOM_PREFIX FIELD"; | ||
|
||
protected final String attributeName; | ||
protected final String attributeContent; | ||
|
||
/** | ||
* Constructs a new AddAttributeCommand instance. | ||
* | ||
* @param attributeName The name of the attribute to be added. | ||
* @param attributeContent The content of the attribute to be added. | ||
*/ | ||
public AddAttributeCommand(String attributeName, String attributeContent) { | ||
requireAllNonNull(attributeName, attributeContent); | ||
this.attributeName = attributeName; | ||
this.attributeContent = attributeContent; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof AddAttributeCommand // instanceof handles nulls | ||
&& attributeName.equals(((AddAttributeCommand) other).attributeName) | ||
&& attributeContent.equals(((AddAttributeCommand) other).attributeContent)); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/seedu/address/logic/commands/attributes/AddGroupAttributeCommand.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,53 @@ | ||
package seedu.address.logic.commands.attributes; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.logic.commands.CommandResult; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.attribute.exceptions.AttributeException; | ||
import seedu.address.model.group.Group; | ||
import seedu.address.model.group.exceptions.GroupOutOfBoundException; | ||
|
||
/** | ||
* Adds a group attribute to the address book. | ||
*/ | ||
public class AddGroupAttributeCommand extends AddAttributeCommand { | ||
|
||
public static final String MESSAGE_SUCCESS = "New field added: %s, with value: %s"; | ||
|
||
private final Index groupIndex; // change this to UUID later | ||
|
||
/** | ||
* Constructs an AddGroupAttributeCommand instance. | ||
* @param groupIndex index of the group. | ||
* @param attributeName the name of the attribute to be added. | ||
* @param attributeContent the content of the attribute to be added. | ||
*/ | ||
public AddGroupAttributeCommand(Index groupIndex, String attributeName, String attributeContent) { | ||
super(attributeName, attributeContent); | ||
requireNonNull(groupIndex); | ||
this.groupIndex = groupIndex; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
try { | ||
Group group = model.getFromFilteredTeams(groupIndex); | ||
group.addAttribute(attributeName, attributeContent); | ||
} catch (GroupOutOfBoundException | AttributeException ae) { | ||
throw new CommandException(ae.getMessage()); | ||
} | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, attributeName, attributeContent)); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (super.equals(other) | ||
&& (other instanceof AddGroupAttributeCommand | ||
&& groupIndex.equals(((AddGroupAttributeCommand) other).groupIndex))); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/seedu/address/logic/commands/attributes/AddPersonAttributeCommand.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,53 @@ | ||
package seedu.address.logic.commands.attributes; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.logic.commands.CommandResult; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.attribute.exceptions.AttributeException; | ||
import seedu.address.model.person.Person; | ||
import seedu.address.model.person.exceptions.PersonOutOfBoundException; | ||
|
||
/** | ||
* Adds a person attribute to the address book. | ||
*/ | ||
public class AddPersonAttributeCommand extends AddAttributeCommand { | ||
|
||
public static final String MESSAGE_SUCCESS = "New field added: %s, with value: %s"; | ||
|
||
private final Index personIndex; // change this to UUID later | ||
|
||
/** | ||
* Constructs an AddPersonAttributeCommand instance. | ||
* @param personIndex index of the person. | ||
* @param attributeName the name of the attribute to be added. | ||
* @param attributeContent the content of the attribute to be added. | ||
*/ | ||
public AddPersonAttributeCommand(Index personIndex, String attributeName, String attributeContent) { | ||
super(attributeName, attributeContent); | ||
requireNonNull(personIndex); | ||
this.personIndex = personIndex; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
try { | ||
Person person = model.getFromFilteredPerson(personIndex); | ||
person.addAttribute(attributeName, attributeContent); | ||
} catch (PersonOutOfBoundException | AttributeException e) { | ||
throw new CommandException(e.getMessage()); | ||
} | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, attributeName, attributeContent)); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (super.equals(other) | ||
&& (other instanceof AddPersonAttributeCommand | ||
&& personIndex.equals(((AddPersonAttributeCommand) other).personIndex))); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/seedu/address/logic/commands/attributes/AddTaskAttributeCommand.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,53 @@ | ||
package seedu.address.logic.commands.attributes; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.logic.commands.CommandResult; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.attribute.exceptions.AttributeException; | ||
import seedu.address.model.task.Task; | ||
import seedu.address.model.task.exceptions.TaskOutOfBoundException; | ||
|
||
/** | ||
* Adds a task attribute to the address book. | ||
*/ | ||
public class AddTaskAttributeCommand extends AddAttributeCommand { | ||
|
||
public static final String MESSAGE_SUCCESS = "New field added: %s, with value: %s"; | ||
|
||
private final Index taskIndex; // change this to UUID later | ||
|
||
/** | ||
* Constructs an AddTaskAttributeCommand instance. | ||
* @param taskIndex index of the task. | ||
* @param attributeName the name of the attribute to be added. | ||
* @param attributeContent the content of the attribute to be added. | ||
*/ | ||
public AddTaskAttributeCommand(Index taskIndex, String attributeName, String attributeContent) { | ||
super(attributeName, attributeContent); | ||
requireNonNull(taskIndex); | ||
this.taskIndex = taskIndex; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
try { | ||
Task task = model.getFromFilteredTasks(taskIndex); | ||
task.addAttribute(attributeName, attributeContent); | ||
} catch (TaskOutOfBoundException | AttributeException ae) { | ||
throw new CommandException(ae.getMessage()); | ||
} | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, attributeName, attributeContent)); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (super.equals(other) | ||
&& (other instanceof AddTaskAttributeCommand | ||
&& taskIndex.equals(((AddTaskAttributeCommand) other).taskIndex))); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/seedu/address/logic/commands/attributes/EditAttributeCommand.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,39 @@ | ||
package seedu.address.logic.commands.attributes; | ||
|
||
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; | ||
|
||
import seedu.address.logic.commands.Command; | ||
|
||
/** | ||
* Edits an existing attribute in the AddressBook. | ||
*/ | ||
public abstract class EditAttributeCommand extends Command { | ||
public static final String COMMAND_WORD = "editfield"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Edits a custom field of a Person/Task/Team in the address book. " | ||
+ "Parameters: CUSTOM_PREFIX FIELD"; | ||
|
||
protected final String attributeName; | ||
protected final String attributeContent; | ||
|
||
/** | ||
* Constructs a new EditAttributeCommand instance. | ||
* | ||
* @param attributeName The name of the attribute to be added. | ||
* @param attributeContent The content of the attribute to be added. | ||
*/ | ||
public EditAttributeCommand(String attributeName, String attributeContent) { | ||
requireAllNonNull(attributeName, attributeContent); | ||
this.attributeName = attributeName; | ||
this.attributeContent = attributeContent; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof EditAttributeCommand // instanceof handles nulls | ||
&& attributeName.equals(((EditAttributeCommand) other).attributeName) | ||
&& attributeContent.equals(((EditAttributeCommand) other).attributeContent)); | ||
} | ||
} |
Oops, something went wrong.