Skip to content

Commit

Permalink
Merge branch 'master' into undo-redo-function-implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mingyu-wan authored Oct 31, 2023
2 parents 913345d + 7681bef commit f8a327b
Show file tree
Hide file tree
Showing 44 changed files with 1,099 additions and 410 deletions.
25 changes: 25 additions & 0 deletions src/main/java/seedu/address/commons/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,31 @@ public static boolean containsWordIgnoreCase(String sentence, String word) {
.anyMatch(preppedWord::equalsIgnoreCase);
}

/**
* Returns true if the {@code sentence} contains the {@code word} as a partial word match.
* Ignores case, and it matches the word even if it's only a part of a larger word.
* <br>examples:<pre>
* containsPartialWordIgnoreCase("ABc def", "abc") == true
* containsPartialWordIgnoreCase("ABc def", "DEF") == true
* containsPartialWordIgnoreCase("ABc def", "AB") == true
* </pre>
* @param sentence cannot be null
* @param word cannot be null, cannot be empty
*/
public static boolean containsPartialWordIgnoreCase(String sentence, String word) {
requireNonNull(sentence);
requireNonNull(word);

String preppedWord = word.trim();
checkArgument(!preppedWord.isEmpty(), "Word parameter cannot be empty");

String preppedSentence = sentence;
String[] wordsInPreppedSentence = preppedSentence.split("\\s+");

return Arrays.stream(wordsInPreppedSentence)
.anyMatch(wordInSentence -> wordInSentence.toLowerCase().contains(preppedWord.toLowerCase()));
}

/**
* Returns a detailed message of the t, including the stack trace.
*/
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@ public class Messages {
public static final String MESSAGE_INAPPLICABLE_PREFIX_USED = "You tried to edit an inapplicable field! "
+ "Please check the prefixes used and try again. \n%1$s";
public static final String MESSAGE_NONEXISTENT_PROJECT = "There is no existing Project with the name: %1$s!";
public static final String MESSAGE_DEVELOPERS_LISTED_OVERVIEW =
"These are the %1$d developers with matching information.";
public static final String MESSAGE_CLIENTS_LISTED_OVERVIEW =
"These are the %1$d clients with matching information.";
public static final String MESSAGE_PROJECTS_LISTED_OVERVIEW =
"These are the %1$d projects with matching information.";
public static String getMessageDevelopersListedOverview(int count) {
return count == 1
? "This is the 1 developer with matching information."
: String.format("These are the %d developers with matching information.", count);
}
public static String getMessageClientsListedOverview(int count) {
return count == 1
? "This is the 1 client with matching information."
: String.format("These are the %d clients with matching information.", count);
}
public static String getMessageProjectsListedOverview(int count) {
return count == 1
? "This is the 1 project with matching information."
: String.format("These are the %d projects with matching information.", count);
}
public static final String MESSAGE_DUPLICATE_FIELDS =
"Multiple values specified for the following single-valued field(s): ";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE;
import static seedu.address.storage.JsonSerializableAddressBook.MESSAGE_DUPLICATE_CLIENT;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
Expand Down Expand Up @@ -51,7 +50,7 @@ public class AddClientCommand extends Command {
+ PREFIX_DOCUMENT + "google.com ";

public static final String MESSAGE_SUCCESS = "New client added: %1$s";
public static final String MESSAGE_DUPLICATE_DEVELOPER = "This client already exists in the address book";
public static final String MESSAGE_DUPLICATE_CLIENT = "This client already exists in the address book";

private final Client toAdd;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class EditProjectCommand extends Command {
+ "[" + PREFIX_DESCRIPTION + "DESCRIPTION] "
+ "[" + PREFIX_DEADLINE + "DEADLINE_DATE,DEADLINE_DESCRIPTION,PRIORITY,IS_DONE]...\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_DEADLINE + "Finish Feature-A by: 09-09-2023"
+ PREFIX_DEADLINE + "Finish Feature-B by: 20-09-2023";
+ PREFIX_DEADLINE + "31-12-2019,Develop front end interface,HIGH,0 "
+ PREFIX_DEADLINE + "01-02-2020,Develop back end,HIGH,0";

private final Index index;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,90 +1,63 @@
package seedu.address.logic.commands.find;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.Messages.getMessageClientsListedOverview;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DOCUMENT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ORGANISATION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE;

import java.util.function.Predicate;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.TabIndex;
import seedu.address.model.Model;
import seedu.address.model.client.Client;
import seedu.address.model.client.DocumentContainsKeywordsPredicate;
import seedu.address.model.client.OrganisationContainsKeywordsPredicate;
import seedu.address.model.person.AddressContainsKeywordsPredicate;
import seedu.address.model.person.EmailContainsKeywordsPredicate;
import seedu.address.model.person.KeywordPredicate;
import seedu.address.model.person.NameContainsKeywordsPredicate;
import seedu.address.model.person.Person;
import seedu.address.model.person.PhoneContainsKeywordsPredicate;
import seedu.address.model.person.ProjectContainsKeywordsPredicate;
import seedu.address.model.person.RoleContainsKeywordsPredicate;

/**
* Finds and lists all persons in address book whose name contains any of the argument keywords.
* Keyword matching is case insensitive.
*/
public class FindClientCommand extends Command {

public static final String COMMAND_WORD = "find-client";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Please Find with the correct input "
+ "Find pr/<Project Name> OR Find r/<Role> OR Find n/<Name>.\n"
+ "Example: " + COMMAND_WORD + " n/ alice bob charlie";

private KeywordPredicate<? extends Person> predicate;

public FindClientCommand(NameContainsKeywordsPredicate namePredicate) {
this.predicate = namePredicate;
}

public FindClientCommand(RoleContainsKeywordsPredicate rolePredicate) {
this.predicate = rolePredicate;
}

public FindClientCommand(AddressContainsKeywordsPredicate addressPredicate) {
this.predicate = addressPredicate;
}

public FindClientCommand(EmailContainsKeywordsPredicate emailPredicate) {
this.predicate = emailPredicate;
}

public FindClientCommand(PhoneContainsKeywordsPredicate phonePredicate) {
this.predicate = phonePredicate;
}


public FindClientCommand(ProjectContainsKeywordsPredicate projectPredicate) {
this.predicate = projectPredicate;
}

public FindClientCommand(DocumentContainsKeywordsPredicate documentPredicate) {
this.predicate = documentPredicate;
}

public FindClientCommand(OrganisationContainsKeywordsPredicate organisationPredicate) {
this.predicate = organisationPredicate;
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Find clients based on various attributes.\n"
+ "Parameters: "
+ "[" + PREFIX_NAME + "NAME_KEYWORDS] "
+ "[" + PREFIX_ROLE + "ROLE_KEYWORDS] "
+ "[" + PREFIX_ADDRESS + "ADDRESS_KEYWORDS] "
+ "[" + PREFIX_EMAIL + "EMAIL_KEYWORDS] "
+ "[" + PREFIX_PHONE + "PHONE_KEYWORDS] "
+ "[" + PREFIX_PROJECT + "PROJECT_KEYWORDS] "
+ "[" + PREFIX_DOCUMENT + "DOCUMENT_KEYWORDS] "
+ "[" + PREFIX_ORGANISATION + "ORGANISATION_KEYWORDS]\n"
+ "Example: " + COMMAND_WORD + " n/John r/client\n";

private Predicate<Client> predicate;

public FindClientCommand(Predicate<Client> predicate) {
this.predicate = predicate;
}

@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.updateFilteredClientList((Predicate<Client>) predicate);
return new CommandResult(
String.format(Messages.MESSAGE_DEVELOPERS_LISTED_OVERVIEW, model.getFilteredDeveloperList().size()), TabIndex.Client);
}
model.updateFilteredClientList(predicate);

int resultCount = model.getFilteredClientList().size();
String message = getMessageClientsListedOverview(resultCount);

return new CommandResult(message, TabIndex.Client);
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof FindClientCommand)) {
return false;
}
Expand All @@ -100,3 +73,4 @@ public String toString() {
.toString();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,99 +2,68 @@

import static java.util.Objects.requireNonNull;

import static seedu.address.logic.Messages.getMessageDevelopersListedOverview;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATEJOINED;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_GITHUBID;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_RATING;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_SALARY;

import java.util.function.Predicate;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;

import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.TabIndex;
import seedu.address.model.Model;
import seedu.address.model.developer.DateJoinedContainsKeywordsPredicate;
import seedu.address.model.developer.Developer;
import seedu.address.model.developer.GithubIdContainsKeywordsPredicate;
import seedu.address.model.developer.RatingContainsKeywordsPredicate;
import seedu.address.model.developer.SalaryContainsKeywordsPredicate;
import seedu.address.model.person.AddressContainsKeywordsPredicate;
import seedu.address.model.person.EmailContainsKeywordsPredicate;
import seedu.address.model.person.KeywordPredicate;
import seedu.address.model.person.NameContainsKeywordsPredicate;
import seedu.address.model.person.Person;
import seedu.address.model.person.PhoneContainsKeywordsPredicate;
import seedu.address.model.person.ProjectContainsKeywordsPredicate;
import seedu.address.model.person.RoleContainsKeywordsPredicate;

/**
* Finds and lists all persons in address book whose name contains any of the argument keywords.
* Keyword matching is case insensitive.
*/

public class FindDeveloperCommand extends Command {

public static final String COMMAND_WORD = "find-developer";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Please Find with the correct input "
+ "Find pr/<Project Name> OR Find r/<Role> OR Find n/<Name>.\n"
+ "Example: " + COMMAND_WORD + " n/ alice bob charlie";

private KeywordPredicate<? extends Person> predicate;

public FindDeveloperCommand(NameContainsKeywordsPredicate namePredicate) {
this.predicate = namePredicate;
}

public FindDeveloperCommand(RoleContainsKeywordsPredicate rolePredicate) {
this.predicate = rolePredicate;
}

public FindDeveloperCommand(AddressContainsKeywordsPredicate addressPredicate) {
this.predicate = addressPredicate;
}

public FindDeveloperCommand(DateJoinedContainsKeywordsPredicate dateJoinedPredicate) {
this.predicate = dateJoinedPredicate;
}

public FindDeveloperCommand(EmailContainsKeywordsPredicate emailPredicate) {
this.predicate = emailPredicate;
}

public FindDeveloperCommand(PhoneContainsKeywordsPredicate phonePredicate) {
this.predicate = phonePredicate;
}

public FindDeveloperCommand(SalaryContainsKeywordsPredicate salaryPredicate) {
this.predicate = salaryPredicate;
}


public FindDeveloperCommand(ProjectContainsKeywordsPredicate projectPredicate) {
this.predicate = projectPredicate;
}

public FindDeveloperCommand(RatingContainsKeywordsPredicate projectPredicate) {
this.predicate = projectPredicate;
}
public FindDeveloperCommand(GithubIdContainsKeywordsPredicate projectPredicate) {
this.predicate = projectPredicate;
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Find developers based on various attributes.\n"
+ "Parameters: "
+ "[" + PREFIX_NAME + "NAME_KEYWORDS] "
+ "[" + PREFIX_ROLE + "ROLE_KEYWORDS] "
+ "[" + PREFIX_ADDRESS + "ADDRESS_KEYWORDS] "
+ "[" + PREFIX_DATEJOINED + "DATE_JOINED_KEYWORDS] "
+ "[" + PREFIX_EMAIL + "EMAIL_KEYWORDS] "
+ "[" + PREFIX_PHONE + "PHONE_KEYWORDS] "
+ "[" + PREFIX_PROJECT + "PROJECT_KEYWORDS] "
+ "[" + PREFIX_SALARY + "SALARY_KEYWORDS] "
+ "[" + PREFIX_RATING + "RATING_KEYWORDS] "
+ "[" + PREFIX_GITHUBID + "GITHUBID_KEYWORDS]\n"
+ "Example: " + COMMAND_WORD + " n/John r/developer\n";

private Predicate<Developer> predicate;

public FindDeveloperCommand(Predicate<Developer> predicate) {
this.predicate = predicate;
}

@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.updateFilteredDeveloperList((Predicate<Developer>) predicate);
return new CommandResult(
String.format(Messages.MESSAGE_DEVELOPERS_LISTED_OVERVIEW, model.getFilteredDeveloperList().size()),
TabIndex.Developer);
}
model.updateFilteredDeveloperList(predicate);

int resultCount = model.getFilteredDeveloperList().size();
String message = getMessageDevelopersListedOverview(resultCount);

return new CommandResult(message, TabIndex.Developer);
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof FindDeveloperCommand)) {
return false;
}
Expand All @@ -110,3 +79,4 @@ public String toString() {
.toString();
}
}

Loading

0 comments on commit f8a327b

Please sign in to comment.