CMPUT301W15T12 / C301Project

Apache License 2.0
3 stars 2 forks source link

ClaimListController API - Time to update your code :P #50

Closed qsjiang closed 9 years ago

qsjiang commented 9 years ago

Hey guys,

Just pushed the first version of "ClaimListController API". Here are two most important points you need to know about the API.

Stable APIs:

All the functions under ClaimListController.java are considered as stable APIs, those functions will stays the same no matter how much the data models have changed. Use them when you need to retrieve/add/delete claims.

Unstable APIs:

All the functions under Claim.java and ClaimList.java are considered as unstable APIs, those functions are subject to change over times. Sometimes you might need to use them, but try to stick with the stable apis as much as possible.

Please post all the questions/problems regarding ClaimListController under this issue.

qsjiang commented 9 years ago

Q: Hey Jim, thank you very much for breaking my code. Now what should I do?

A: You are welcome, here is what you need to do.

AddClaimActivity.java

Lines 89 - 91:

    Claim claim = new Claim(name, sdate, edate,description, username);
    ClaimListController.getClaimList().addClaim(claim);
    ClaimListController.saveClaimList();

Simplely change to

    claimListController.addClaim(name, sdate, edate,description, user);

Line 100:

    ...ClaimListController.getClaimList().getClaim(0)...

Use this instead

    claimListController.getClaim(int id);

AddCommentsActivity.java

Line 25:

    ...ClaimListController.getClaimList().getClaim(id);...

Change to

    claimListController.getClaim(id);

ApproverClaimActivity.java

Line 40

same as AddCommentsActivity.java

ApproverItemActivity.java

Line 29

same as AddCommentsActivity.java

ApproverListActivity.java

Line 35 and Line 53

    ...ClaimListController.getClaimList().getSubmittedclaims()...

Change to

    claimListController.filterByStatus(String "StatusHere")

Line 50

    ...ClaimListController.getClaimList().addListener(....

Change to

    claimListController.addListener(listener);

ClaimActivity.java

Line 40, 83

same as AddCommentsActivity.java

Line 125

same as ApproverListActivity Line 50

Line 164

            ClaimListController.getClaimList().removeClaim(id);

Change to

            claimListController.removeClaim(id);

ClaimListActivity

Line 32

            ClaimListController.getClaimList().getClaim(0)

Change to

            claimListController.getClaim(id)

Line 77

same as ApproverListActivity Line 50

Line 82

            ClaimListController.getClaimList().getUserClaims(Username);

Change to

            claimListController.filterByClaimant(user);

EmailActivity.java, ExpenseItemActivity.java, SeeCommentsActivitiy.java and ViewPhotoActivity.java

same as AddCommentsActivity.java

(Note: claimListController is an instance of ClaimListController, you only need to create one claimListController instance inside each of your activity. "ClaimListController claimListController = new ClaimListController();")

megsum commented 9 years ago

You're awesome! Thanks Jim, I shall do that tomorrow!

vanbelle commented 9 years ago

@LeahGabrielle , @megsum I've implemented all these changes, so that I could run the program without errors, just continue where you left off.

LeahGabrielle commented 9 years ago

Is there anything for adding an expense item to a claim? Where would that be/how should I be accessing a function for that?

qsjiang commented 9 years ago

Hi Leah, They are not there at this moment. I'll add them in a few hours

megsum commented 9 years ago

@qsjiang @Pengwin-man @IchigoKIl Hey! I was just wondering if it would be possible to get a way in the ClaimListController to add tags for a specific claim. Thanks!

qsjiang commented 9 years ago

Hey @megsum, Just added two new functions into ClaimListController. (Details see commit 9829814769ba309f3e6e02ef432ac57bf7aedc6e)

        public void addTagToClaim(int claimId, String tag);
        public ArrayList<String> getTagListFromClaim(int claimId)
vanbelle commented 9 years ago

Right now we are using getting a claim and then calling claim.getTotal(); for the total, however even after making an exense item it always returns an empty list. Did you make another function we are supposed to be using? Or is the expense item not saving?

qsjiang commented 9 years ago

@vanbelle I will look into it, and let you know later tonight.

vanbelle commented 9 years ago

Another useful function would be an update function for the edit page. i.e: claim.updateClaim(string name, startdate, enddate, description, taglist, destinationlist) which keeps approver, claimant,id,comments etc. and uses set functions or something. might need notify listeners?

qsjiang commented 9 years ago

Hi @vanbelle thanks for the feedback,

There was a bug in the previous getTotal() function. It has been fixed in commit 9f45947713d97e3d28744e75891f4de37437c926

About adding functions into the ClaimListController: There are still a few things we need to discuss before nailing getTotal() and updateClaim() into our Stable APIs. For example, "uniqueness of expenseItem", "return object type of getTotal" and others...

We will discuss them next time we meet, for now just use the unstable version inside Claim class.