Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with rendering correct data #142

Open
C-likethis123 opened this issue Oct 23, 2019 · 1 comment
Open

Problems with rendering correct data #142

C-likethis123 opened this issue Oct 23, 2019 · 1 comment

Comments

@C-likethis123
Copy link

Please read up on how to write a good question

Environment

Describe your development environment

  • IntelliJ version: IntelliJ IDEA 2019.2 (Ultimate Edition)
  • Java version: java 12.0.2
  • Operating system version: macOS 10.14.6
  • other packages' versions

Issue

For context, our team is trying to build an organ-matching desktop application, which matches Patients to Donors. Currently, I am trying to add in a command to match a particular Patient to all the donors in the database. After matching the Patient to the Donor, a list with matching Donors and its success rate should be displayed.

Example output:
Screenshot 2019-10-23 at 4 29 09 PM

The issue comes when instead of displaying the Donors and its success rate of matching, it displays the Donors only, without the match result. There is no pattern as to when it displays the wrong output. For example, the first time I type in match ic/NRIC, it displays the Donors with the match results. But when I type in the same command, it displays the Donors without the match results. I have tried many combinations of commands but still cannot find a reason as to why this problem occurs.

How to replicate the bug

  1. Launch the application
  2. Type in the following commands to add testing data:
add t/patient n/John Doe ic/S1234568R p/98765432 a/21 pr/high b/A tt/1,2,3,4,5,6 o/kidney d/S1111111A

add t/donor n/John Doe Donor ic/S1234562R p/98888888 a/21 b/O tt/1,2,3,4,5,6 o/kidney exp/20-Jan-2020
  1. Type in the following command: match ic/S1234568R. Repeat the typing of this command several times.

Code/Log Trace

Here is my branch where this feature is added: https://github.com/AY1920S1-CS2103T-T13-1/main/tree/add-match-feature/

Here are some details about the implementation of this feature that may help.

  1. When we type in match ic/S1234567R, the user input is parsed by the MatchCommandParser to create a MatchCommand. The MatchCommand executes the matching in the ModelManager and updates the filteredPersonList in ModelManager.
  2. To display the match results, in PersonListPanel.java, there is a PersonListViewCell class with an updateItem method to decide what should be rendered:
/**
     * Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}.
     */
    class PersonListViewCell extends ListCell<Person> {
        @Override
        protected void updateItem(Person person, boolean empty) {
            super.updateItem(person, empty);

            if (empty || person == null) {
                setGraphic(null);
                setText(null);
            } else {
                if (person instanceof Doctor) {
                    setGraphic(new DoctorCard((Doctor) person, getIndex() + 1).getRoot());
                } else if (person instanceof Donor) {
                    Donor donor = (Donor) person;
                    if (donor.isMatched()) {
                        setGraphic(new MatchCard(donor, getIndex() + 1).getRoot());
                        donor.setMatched(false);
                    } else {
                        setGraphic(new DonorCard(donor, getIndex() + 1).getRoot());
                    }
                } else if (person instanceof Patient) {
                    setGraphic(new PatientCard((Patient) person, getIndex() + 1).getRoot());
                } else {
                    setGraphic(new PersonCard(person, getIndex() + 1).getRoot());
                }
            }
        }
    }
@damithc
Copy link
Collaborator

damithc commented Oct 23, 2019

If you can reliably replicate the problem, have you tried putting a break point at the start of the relevant code segment and then stepping through the code in debug mode to find exactly what happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants