Skip to content

Commit

Permalink
Merge branch 'master' into UserGuide
Browse files Browse the repository at this point in the history
  • Loading branch information
yorklim committed Mar 20, 2024
2 parents 7aa97e4 + ea878c4 commit 12275f4
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 57 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,3 @@ jobs:
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
paths-ignore: "main/java/seedu/address/ui/**/*"
14 changes: 7 additions & 7 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,21 @@ public static Set<Tag> parseTags(Collection<String> tags) throws ParseException
* Leading and trailing whitespaces will be trimmed.
*
* @param policyName the name
* @param policyID the id
* @param policyId the id
* @return the policy
* @throws ParseException if the given {@code policyName} or {@code policyId} is invalid.
*/
public static Policy parsePolicyInfo(String policyName, String policyID) throws ParseException {
requireNonNull(policyName, policyID);
public static Policy parsePolicyInfo(String policyName, String policyId) throws ParseException {
requireNonNull(policyName, policyId);
String trimmedPolicyName = policyName.trim();
String trimmedPolicyID = policyID.trim();
String trimmedPolicyId = policyId.trim();
if (!Policy.isValidName(trimmedPolicyName)) {
throw new ParseException(Policy.MESSAGE_CONSTRAINTS_NAME);
}
if (!Policy.isValidID(trimmedPolicyID)) {
if (!Policy.isValidId(trimmedPolicyId)) {
throw new ParseException(Policy.MESSAGE_CONSTRAINTS_ID);
}
return new Policy(trimmedPolicyName, trimmedPolicyID);
return new Policy(trimmedPolicyName, trimmedPolicyId);
}

/**
Expand All @@ -202,7 +202,7 @@ public static Policy parsePolicyInfo(String policyName, String policyID) throws
public static String parsePolicyId(String policyId) throws ParseException {
requireNonNull(policyId);
String trimmedPolicyId = policyId.trim();
if (!Policy.isValidID(trimmedPolicyId)) {
if (!Policy.isValidId(trimmedPolicyId)) {
throw new ParseException(Policy.MESSAGE_CONSTRAINTS_ID);
}
return trimmedPolicyId;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/person/PolicyList.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public boolean hasConflictingPolicyId(Policy newPolicy) {
assert newPolicy != null;
boolean isConflicting = false;
for (Policy p: policyList) {
if (p.hasSameID(newPolicy)) {
if (p.hasSameId(newPolicy)) {
isConflicting = true;
break;
}
Expand Down
40 changes: 26 additions & 14 deletions src/main/java/seedu/address/model/policy/Policy.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,35 @@ public class Policy {
/**
* The Policy id.
*/
public final String policyID;
private final PolicyType type;
public final String policyId;
private final PolicyType policyType;


/**
* Instantiates a new Policy.
*
* @param policyName the policy name
* @param policyID the policy id
* @param policyId the policy id
*/
public Policy(String policyName, String policyID) {
requireNonNull(policyName, policyID);
public Policy(String policyName, String policyId) {
requireNonNull(policyName, policyId);
checkArgument(isValidName(policyName), MESSAGE_CONSTRAINTS_NAME);
checkArgument(isValidID(policyID), MESSAGE_CONSTRAINTS_ID);
checkArgument(isValidId(policyId), MESSAGE_CONSTRAINTS_ID);
this.policyName = policyName;
this.policyID = policyID;
this.type = PolicyType.DEFAULT;
this.policyId = policyId;
this.policyType = PolicyType.DEFAULT;
}

public String getPolicyId() {
return policyId;
}

public String getPolicyName() {
return policyName;
}

public PolicyType getPolicyType() {
return policyType;
}

/**
Expand All @@ -58,7 +70,7 @@ public Policy(String policyName, String policyID) {
* @return the boolean
*/
public boolean isID(String testID) {
return testID.equals(policyID);
return testID.equals(policyId);
}

/**
Expand All @@ -77,7 +89,7 @@ public static boolean isValidName(String test) {
* @param test the test
* @return the boolean
*/
public static boolean isValidID(String test) {
public static boolean isValidId(String test) {
return test.matches(VALIDATION_ID_REGEX);
}

Expand All @@ -87,12 +99,12 @@ public static boolean isValidID(String test) {
* @param policy the policy
* @return the boolean
*/
public boolean hasSameID(Policy policy) {
return policyID.equals(policy.policyID);
public boolean hasSameId(Policy policy) {
return policyId.equals(policy.policyId);
}
@Override
public String toString() {
return "Name:" + policyName + ", Type:" + type + ", Policy ID:" + policyID;
return "Name:" + policyName + ", Type:" + policyType + ", Policy ID:" + policyId;
}

@Override
Expand All @@ -106,6 +118,6 @@ public boolean equals(Object obj) {
}

Policy policy = (Policy) obj;
return policyID.equals(policy.policyID) && policyName.equals(policy.policyName);
return policyId.equals(policy.policyId) && policyName.equals(policy.policyName);
}
}
12 changes: 6 additions & 6 deletions src/main/java/seedu/address/storage/JsonAdaptedPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class JsonAdaptedPolicy {

private final String policyName;
private final String policyID;
private final String policyId;

/**
* Constructs a {@code JsonAdaptedPolicy} with the given {@code policyName, policyID}.
Expand All @@ -21,20 +21,20 @@ class JsonAdaptedPolicy {
public JsonAdaptedPolicy(String policyDetails) {
String[] args = policyDetails.split(",");
this.policyName = args[0];
this.policyID = args[1];
this.policyId = args[1];
}

/**
* Converts a given {@code Policy} into this class for Jackson use.
*/
public JsonAdaptedPolicy(Policy source) {
policyName = source.policyName;
policyID = source.policyID;
policyId = source.policyId;
}

@JsonValue
public String getPolicyDetails() {
return policyName + "," + policyID;
return policyName + "," + policyId;
}

/**
Expand All @@ -46,10 +46,10 @@ public Policy toModelType() throws IllegalValueException {
if (!Policy.isValidName(policyName)) {
throw new IllegalValueException(Policy.MESSAGE_CONSTRAINTS_NAME);
}
if (!Policy.isValidID(policyID)) {
if (!Policy.isValidId(policyId)) {
throw new IllegalValueException(Policy.MESSAGE_CONSTRAINTS_ID);
}
return new Policy(policyName, policyID);
return new Policy(policyName, policyId);
}

}
31 changes: 17 additions & 14 deletions src/main/java/seedu/address/ui/ClientPolicyTable.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package seedu.address.ui;

import javafx.fxml.FXML;
// import javafx.scene.control.TableColumn;
// import javafx.scene.control.TableView;
// import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.Region;
import seedu.address.model.person.PolicyList;
import seedu.address.model.policy.Policy;


/**
Expand All @@ -14,14 +16,14 @@ public class ClientPolicyTable extends UiPart<Region> {

private static final String FXML = "ClientPolicyTable.fxml";

/*
@FXML
private TableView<Policy> policyTableView;
@FXML
private TableColumn<Policy, String> policyId;
@FXML
private TableColumn<Policy, String> policyName;
*/
// @FXML
// private TableColumn<Policy, String> policyType;

/**
* Creates an empty {@code ClientPolicyTable}.
Expand All @@ -30,14 +32,15 @@ public ClientPolicyTable() {
super(FXML);
}

// /**
// * Creates a {@code ClientPolicyTable} with the given {@code }.
// */
// public ClientPolicyTable() {
// // argument should be some kind of list? ObservableList maybe
// super(FXML);
// // policyId.setCellValueFactory(new PropertyValueFactory<Policy, String>("policyId"));
// // policyTableView.setItems(xxx);
// }
/**
* Creates a {@code ClientPolicyTable} with the given {@code policyList}.
*/
public ClientPolicyTable(PolicyList policyList) {
super(FXML);
policyId.setCellValueFactory(new PropertyValueFactory<Policy, String>("policyId"));
policyName.setCellValueFactory(new PropertyValueFactory<Policy, String>("policyName"));
// policyType.setCellValueFactory(new PropertyValueFactory<Policy, String>("policyType"));
policyTableView.setItems(policyList.policyList);
}

}
14 changes: 8 additions & 6 deletions src/main/java/seedu/address/ui/ClientViewPanel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.ui;

import seedu.address.model.person.Person;
import seedu.address.model.person.PolicyList;

/**
* A UI Class that encapsulates {@code ClientDetailsCard} and {@code ClientPolicyTable}.
Expand All @@ -20,7 +21,7 @@ public ClientViewPanel(Person person) {
this.clientPolicyTable = new ClientPolicyTable();
} else {
this.clientDetailsCard = new ClientDetailsCard(person);
this.clientPolicyTable = new ClientPolicyTable();
this.clientPolicyTable = new ClientPolicyTable(person.getPolicyList());
}
}

Expand All @@ -39,17 +40,18 @@ public void updateClientDetailsCard(Person person) {
clientDetailsCard = new ClientDetailsCard(person);
}

/*
public void updateClientPolicyTable(xxx) {
clientPolicyTable = new ClientPolicyTable(xxx);
}
/**
* Updates the {@code ClientPolicyTable} with new {@code ObservableList<Policy>}
*/
public void updateClientPolicyTable(PolicyList policyList) {
clientPolicyTable = new ClientPolicyTable(policyList);
}

/**
* Updates the {@code ClientViewPanel} with new {@code Person}.
*/
public void updateClientViewPanel(Person person) {
updateClientDetailsCard(person);
// updateClientPolicyTable(xxx);
updateClientPolicyTable(person.getPolicyList());
}
}
1 change: 1 addition & 0 deletions src/main/resources/view/ClientPolicyTable.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<columns>
<TableColumn fx:id="policyId" editable="false" minWidth="80.0" prefWidth="100.0" reorderable="false" text="Policy ID" />
<TableColumn fx:id="policyName" editable="false" minWidth="120.0" prefWidth="300.0" reorderable="false" text="Policy Name" />
<!-- <TableColumn fx:id="policyType" editable="false" minWidth="120.0" prefWidth="300.0" reorderable="false" text="Policy Type" /> -->
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/seedu/address/model/person/PolicyListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void deletePolicy() {
.observableArrayList(expectedPolicyObservableList);
actualPolicyObservableList.add(policy3);
PolicyList actualPolicyList = new PolicyList(actualPolicyObservableList);
actualPolicyList.deletePolicy(policy3.policyID);
actualPolicyList.deletePolicy(policy3.policyId);
assertEquals(actualPolicyList, expectedPolicyList);
}

Expand All @@ -64,8 +64,8 @@ public void hasPolicy() {
policyObservableList.add(policy3);
PolicyList actualPolicyList = new PolicyList(policyObservableList);

assertTrue(actualPolicyList.hasPolicy(policy2.policyID));
assertFalse(actualPolicyList.hasPolicy(policy4.policyID));
assertTrue(actualPolicyList.hasPolicy(policy2.policyId));
assertFalse(actualPolicyList.hasPolicy(policy4.policyId));
}

@Test
Expand Down
23 changes: 19 additions & 4 deletions src/test/java/seedu/address/model/policy/PolicyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ public class PolicyTest {

private static final Policy policy = new Policy(VALID_NAME, VALID_ID);

@Test
public void getPolicyId() {
assertEquals(policy.getPolicyId(), VALID_ID);
}

@Test
public void getPolicyName() {
assertEquals(policy.getPolicyName(), VALID_NAME);
}

@Test
public void getPolicyType() {
assertEquals(policy.getPolicyType(), PolicyType.DEFAULT);
}

@Test
public void isIdTestTrue() {
assertTrue(policy.isID(VALID_ID));
Expand All @@ -35,22 +50,22 @@ public void isValidNameTestFalse() {

@Test
public void isValidIdTestTrue() {
assertTrue(Policy.isValidID(VALID_ID));
assertTrue(Policy.isValidId(VALID_ID));
}

@Test
public void isValidIdTestFalse() {
assertFalse(Policy.isValidID(INVALID_ID));
assertFalse(Policy.isValidId(INVALID_ID));
}

@Test
public void hasSameIdTestTrue() {
assertTrue(policy.hasSameID(policy));
assertTrue(policy.hasSameId(policy));
}
@Test
public void hasSameIdTestFalse() {
Policy otherPolicy = new Policy("Health", "456");
assertFalse(policy.hasSameID(otherPolicy));
assertFalse(policy.hasSameId(otherPolicy));
}

@Test
Expand Down

0 comments on commit 12275f4

Please sign in to comment.