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

separated 'admins-and-groupings' into 2 endpoints 'groupings-admins' & 'all-groupings' #511

Merged

Conversation

mikhail-shkaralevich
Copy link
Contributor

Ticket Link

Ticket

List of squashed commits

  • Add new endpoints 'groupings-admins' & 'all-groupings'.
  • Create new class GroupingAdmins to store a group of admins
  • Create new class GroupingAll to store a list of all groupings
  • Modify function groupingPaths() to make sure that only admins have access to all the groupings
  • Write tests
  • Cleanup code

Test Checklist

  • Exhibits Clear Code Structure:
  • Project Unit Tests Passed:
  • Project Integration Tests Passed:
  • Executes Expected Functionality:
  • Tested For Incorrect/Unexpected Inputs:

@JorWo
Copy link
Contributor

JorWo commented Dec 16, 2023

Overall, great work! Also make sure to update your code style file in IntelliJ and fixup the import order in all the Java files. You can send me or Isaac a message if you have any questions.

I will review your UI PR once the changes have been made to this PR because you are likely to have to make changes to the UI side too.

@mikhail-shkaralevich mikhail-shkaralevich force-pushed the dev-misha-1560 branch 2 times, most recently from 39a2c6e to 8ffd0f3 Compare December 19, 2023 01:00
@JorWo
Copy link
Contributor

JorWo commented Dec 19, 2023

Final thing, make sure the functions and classes created/touched in this PR have 100% test coverage or as close as to 100% as you can. Here is how to check the test coverage percentage: https://uhawaii.atlassian.net/wiki/spaces/SITARd/pages/12943618/jaCoCo+Code+Coverage

@mikhail-shkaralevich mikhail-shkaralevich force-pushed the dev-misha-1560 branch 2 times, most recently from 247c598 to 8490dd7 Compare December 20, 2023 22:01
Comment on lines 62 to 68
public GroupingAdmins groupingAdmins (String adminUhIdentifier) {
logger.info(String.format("groupingAdmins; adminUhIdentifier: %s;", adminUhIdentifier));
if (!memberService.isAdmin(adminUhIdentifier)) {
throw new AccessDeniedException();
}
AdminListsHolder adminListsHolder = new AdminListsHolder();
List<String> adminGrouping = Arrays.asList(GROUPING_ADMINS);
Group admin = getMembers(adminUhIdentifier, adminGrouping).get(GROUPING_ADMINS);
adminListsHolder.setAllGroupingPaths(groupingsService.allGroupingPaths());
adminListsHolder.setAdminGroup(admin);
return adminListsHolder;
Group admin = this.getMembers(adminUhIdentifier, Arrays.asList(GROUPING_ADMINS)).get(GROUPING_ADMINS);
return new GroupingAdmins(admin);
Copy link
Contributor

@JorWo JorWo Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a better idea for this function, let's change up the GroupingAdmins to store a GroupingGroupMembers (Note the "s" only after Members) instead of a Group. That would mean that grouperApiService.getMembersResult() should be called in this function. Also notice the constructor for GroupingGroupMembers takes in GetMembersResult. Making this change will match the code with our current API design.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also could you remove the space before (string adminUhIdentifier) on line 62? Thanks!

Copy link
Contributor Author

@mikhail-shkaralevich mikhail-shkaralevich Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package edu.hawaii.its.api.groupings;

import edu.hawaii.its.api.wrapper.GetMembersResult;
import edu.hawaii.its.api.wrapper.Subject;

import java.util.List;

public class GroupingAdmins {

    private GroupingGroupMembers adminGroupingGroupMembers;

    public GroupingAdmins() {
        this.adminGroupingGroupMembers = new GroupingGroupMembers();
        this.adminGroupingGroupMembers.setResultCode("FAILURE");
    }

    public GroupingAdmins(GetMembersResult getMembersResult) {
        this.adminGroupingGroupMembers = new GroupingGroupMembers(getMembersResult);
        this.adminGroupingGroupMembers.setResultCode("SUCCESS");
    }

    public List<GroupingGroupMember> getAdminGroupMembers() { return adminGroupingGroupMembers.getMembers(); }

    public void setAdminGroupMembers(List<Subject> adminGroup) { this.adminGroupingGroupMembers.setMembers(adminGroup); }

    public String getResultCode() { return this.adminGroupingGroupMembers.getResultCode(); }
}

Does it look right?

Copy link
Contributor Author

@mikhail-shkaralevich mikhail-shkaralevich Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it have a 3rd constructor taking List<Subjects> as a parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused about how this should be implemented and what i need to return in the getters and set in the setters. Is it List<Subject> or GroupingGroupMembers

Copy link
Contributor

@JorWo JorWo Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GroupingAdmins should continue to implement GroupingResult. The adminGroupingGroupMembers can just be admins for short.

You only need a 3rd constructor if you will use it.

The getter should be of type GroupingGroupMembers. The setter in this case is not needed and should be used as private a function to help with your constructors. You can see the other classes in the /groupings folder that do it like that.

@JorWo
Copy link
Contributor

JorWo commented Dec 27, 2023

Sorry for the confusion, I took a deeper look into the GroupingGroupMembers class and it would seem better to remove the GroupingAdmins class and instead use the GroupingGroupMembers as the return type for grouping admins. That way we do not create any redundant classes.

@mikhail-shkaralevich mikhail-shkaralevich force-pushed the dev-misha-1560 branch 5 times, most recently from 22c3f66 to b57a9b0 Compare January 9, 2024 22:05
@mikhail-shkaralevich mikhail-shkaralevich force-pushed the dev-misha-1560 branch 2 times, most recently from 94b7fef to 5770b0e Compare January 18, 2024 22:13
Copy link
Contributor

@JorWo JorWo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@JorWo JorWo requested a review from mhodgesatuh January 19, 2024 00:03
@JorWo JorWo merged commit d6a914b into uhawaii-system-its-ti-iam:main Jan 19, 2024
14 checks passed
mikhail-shkaralevich added a commit to mikhail-shkaralevich/uh-groupings-api that referenced this pull request Oct 18, 2024
mikhail-shkaralevich added a commit to mikhail-shkaralevich/uh-groupings-api that referenced this pull request Nov 1, 2024
mikhail-shkaralevich added a commit to mikhail-shkaralevich/uh-groupings-api that referenced this pull request Nov 8, 2024
mikhail-shkaralevich added a commit to mikhail-shkaralevich/uh-groupings-api that referenced this pull request Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants