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

Refactored the getSysUserId Method into a Single Class #1303

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

Ariho-Seth
Copy link

@Ariho-Seth Ariho-Seth commented Nov 8, 2024

Pull Requests Requirements

  • The PR title includes a brief description of the work done, including the
    Issue number if applicable.
  • The PR includes a video showing the changes for the work done.
  • The PR title follows conventional commit label standards.
  • The changes confirm to the OpenElis Global x3 Styleguide and design
    documentation.
  • The changes include tests or are validated by existing tests.
  • I have read and agree to the Contributing Guidelines of this project.

Summary

Screenshots

VsCode

Refactor getSysUserId into a Separate Class

#1222

Other

Created a new class ie ControllerUtills and moved the protected String getSysUserId method into the new class. Then refactored all the classes that were initialy extending the BaseRestController to extend the ControllerUtills class

Copy link
Collaborator

@mozzy11 mozzy11 left a comment

Choose a reason for hiding this comment

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

Thanks @Ariho-Seth for attempting this.

You need only to create a new Class ControllerUtills under the util sub-folder and move the getSysUserId there . We could add more commnUtils there

The new ControllerUtills Class shoud not implement IActionConstants . Leave that for or the BaseController

Then let the BaseController and BaseRestController Classes extend the new ControllerUtills .

The rest of the controller Classes should only Extend either BaseController or BaseRestController respectively as it has been.

@Ariho-Seth
Copy link
Author

Hello @mozzy11 , please checkout that and tell me whether the solution is okay now! Thanks

@@ -29,7 +29,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ViewNonConformEventsRestController {
public class ViewNonConformEventsRestController extends ControllerUtills {
Copy link
Collaborator

@mozzy11 mozzy11 Nov 19, 2024

Choose a reason for hiding this comment

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

This is a Rest Controller oler so it should extend the BaseRestController instead

@@ -33,7 +33,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ReportNonConformEventsRestController {
public class ReportNonConformEventsRestController extends ControllerUtills {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a Rest Controller oler so it should extend the BaseRestController instead

@@ -26,12 +26,10 @@

@RestController
@RequestMapping(value = "/rest")
public class NonConformingEventsCorrectionActionRestController {
public class NonConformingEventsCorrectionActionRestController extends ControllerUtills {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a Rest Controller oler so it should extend the BaseRestController instead

@@ -31,12 +31,11 @@

@RequestMapping("/rest")
@RestController
public class NotificationRestController {
public class NotificationRestController extends ControllerUtills {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a Rest Controller oler so it should extend the BaseRestController instead


public class ControllerUtills {

private static final String USER_SESSION_DATA = "userSessionData";
Copy link
Collaborator

@mozzy11 mozzy11 Nov 19, 2024

Choose a reason for hiding this comment

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

you dont need to declare this variable again just import as
import org.openelisglobal.common.action.IActionConstants;

private static final String USER_SESSION_DATA = "userSessionData";

protected String getSysUserId(HttpServletRequest request) {
UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
Copy link
Collaborator

Choose a reason for hiding this comment

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

just import this as IActionConstants.USER_SESSION_DATA

@Ariho-Seth
Copy link
Author

Hello @mozzy11 I added the requested changes, Is it now good to go?

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.

2 participants