Skip to content

Commit

Permalink
Share status report params
Browse files Browse the repository at this point in the history
  • Loading branch information
slominskir committed Jan 2, 2024
1 parent 2b6a6c3 commit cd9adf8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ public void validate(GroupStatusParams params) {

@Override
public void store(GroupStatusParams params) {
/* Note: We store each field indivdually as we want to re-use amoung screens*/
/* Note: We store each field individually as we want to re-use among screens*/
/* Note: We use a 'SECURE' cookie so session changes every request unless over SSL/TLS */
/* Note: We use an array regardless if the parameter is multi-valued because a null array means no page ever set this param before vs empty array or array with null elements means someone set it, but value is empty*/
HttpSession session = request.getSession(true);

session.setAttribute("groupStatusReportDestinationId[]",
session.setAttribute(OverallStatusUrlParamHandler.SESSION_STATUS_REPORT_DESTINATION_ID,
params.getDestinationIdArray() == null ? new BigInteger[0] : params.getDestinationIdArray());
session.setAttribute("groupStatusReportCategoryId[]", new BigInteger[]{params.getCategoryId()});
session.setAttribute("groupStatusReportSystemId[]", new BigInteger[]{params.getSystemId()});
session.setAttribute("groupStatusReportRegionId[]", new BigInteger[]{params.getRegionId()});
session.setAttribute(OverallStatusUrlParamHandler.SESSION_STATUS_REPORT_CATEGORY_ID, new BigInteger[]{params.getCategoryId()});
session.setAttribute(OverallStatusUrlParamHandler.SESSION_STATUS_REPORT_SYSTEM_ID, new BigInteger[]{params.getSystemId()});
session.setAttribute(OverallStatusUrlParamHandler.SESSION_STATUS_REPORT_REGION_ID, new BigInteger[]{params.getRegionId()});
session.setAttribute("groupStatusReportChart[]", new String[]{params.getChart()});
}

Expand All @@ -76,14 +76,11 @@ public GroupStatusParams defaults() {
public GroupStatusParams materialize() {
GroupStatusParams defaultValues = defaults();

/* Note: We store each field indivdually as we want to re-use amoung screens*/
/* Note: We use a 'SECURE' cookie so session changes every request unless over SSL/TLS */
/* Note: We use an array regardless if the parameter is multi-valued because a null array means no page ever set this param before vs empty array or array with null elements means someone set it, but value is empty*/
HttpSession session = request.getSession(true);
BigInteger[] destinationIdArray = (BigInteger[]) session.getAttribute("groupStatusReportDestinationId[]");
BigInteger[] categoryIdArray = (BigInteger[]) session.getAttribute("groupStatusReportCategoryId[]");
BigInteger[] systemIdArray = (BigInteger[]) session.getAttribute("groupStatusReportSystemId[]");
BigInteger[] regionIdArray = (BigInteger[]) session.getAttribute("groupStatusReportRegionId[]");
BigInteger[] destinationIdArray = (BigInteger[]) session.getAttribute(OverallStatusUrlParamHandler.SESSION_STATUS_REPORT_DESTINATION_ID);
BigInteger[] categoryIdArray = (BigInteger[]) session.getAttribute(OverallStatusUrlParamHandler.SESSION_STATUS_REPORT_CATEGORY_ID);
BigInteger[] systemIdArray = (BigInteger[]) session.getAttribute(OverallStatusUrlParamHandler.SESSION_STATUS_REPORT_SYSTEM_ID);
BigInteger[] regionIdArray = (BigInteger[]) session.getAttribute(OverallStatusUrlParamHandler.SESSION_STATUS_REPORT_REGION_ID);
String[] chartArray = (String[]) session.getAttribute("groupStatusReportChart[]");

BigInteger categoryId = defaultValues.getCategoryId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

public class OverallStatusUrlParamHandler implements UrlParamHandler<OverallStatusParams> {

public static final String SESSION_STATUS_REPORT_DESTINATION_ID = "statusReportDestinationId[]";
public static final String SESSION_STATUS_REPORT_CATEGORY_ID = "statusReportCategoryId[]";
public static final String SESSION_STATUS_REPORT_SYSTEM_ID = "statusReportSystemId[]";
public static final String SESSION_STATUS_REPORT_REGION_ID = "statusReportRegionId[]";

private final HttpServletRequest request;
private final BigInteger[] defaultDestinationIdArray;

Expand Down Expand Up @@ -50,16 +55,16 @@ public void validate(OverallStatusParams params) {

@Override
public void store(OverallStatusParams params) {
/* Note: We store each field indivdually as we want to re-use amoung screens*/
/* Note: We store each field individually as we want to re-use among screens*/
/* Note: We use a 'SECURE' cookie so session changes every request unless over SSL/TLS */
/* Note: We use an array regardless if the parameter is multi-valued because a null array means no page ever set this param before vs empty array or array with null elements means someone set it, but value is empty*/
HttpSession session = request.getSession(true);

session.setAttribute("overallStatusReportDestinationId[]",
session.setAttribute(SESSION_STATUS_REPORT_DESTINATION_ID,
params.getDestinationIdArray() == null ? new BigInteger[0] : params.getDestinationIdArray());
session.setAttribute("overallStatusReportCategoryId[]", new BigInteger[]{params.getCategoryId()});
session.setAttribute("overallStatusReportSystemId[]", new BigInteger[]{params.getSystemId()});
session.setAttribute("overallStatusReportRegionId[]", new BigInteger[]{params.getRegionId()});
session.setAttribute(SESSION_STATUS_REPORT_CATEGORY_ID, new BigInteger[]{params.getCategoryId()});
session.setAttribute(SESSION_STATUS_REPORT_SYSTEM_ID, new BigInteger[]{params.getSystemId()});
session.setAttribute(SESSION_STATUS_REPORT_REGION_ID, new BigInteger[]{params.getRegionId()});
session.setAttribute("overallStatusReportGroupId[]", new BigInteger[]{params.getGroupId()});
}

Expand All @@ -76,14 +81,11 @@ public OverallStatusParams defaults() {
public OverallStatusParams materialize() {
OverallStatusParams defaultValues = defaults();

/* Note: We store each field indivdually as we want to re-use amoung screens*/
/* Note: We use a 'SECURE' cookie so session changes every request unless over SSL/TLS */
/* Note: We use an array regardless if the parameter is multi-valued because a null array means no page ever set this param before vs empty array or array with null elements means someone set it, but value is empty*/
HttpSession session = request.getSession(true);
BigInteger[] destinationIdArray = (BigInteger[]) session.getAttribute("overallStatusReportDestinationId[]");
BigInteger[] categoryIdArray = (BigInteger[]) session.getAttribute("overallStatusReportCategoryId[]");
BigInteger[] systemIdArray = (BigInteger[]) session.getAttribute("overallStatusReportSystemId[]");
BigInteger[] regionIdArray = (BigInteger[]) session.getAttribute("overallStatusReportRegionId[]");
BigInteger[] destinationIdArray = (BigInteger[]) session.getAttribute(SESSION_STATUS_REPORT_DESTINATION_ID);
BigInteger[] categoryIdArray = (BigInteger[]) session.getAttribute(SESSION_STATUS_REPORT_CATEGORY_ID);
BigInteger[] systemIdArray = (BigInteger[]) session.getAttribute(SESSION_STATUS_REPORT_SYSTEM_ID);
BigInteger[] regionIdArray = (BigInteger[]) session.getAttribute(SESSION_STATUS_REPORT_REGION_ID);
BigInteger[] groupIdArray = (BigInteger[]) session.getAttribute("overallStatusReportGroupId[]");

BigInteger categoryId = defaultValues.getCategoryId();
Expand Down

0 comments on commit cd9adf8

Please sign in to comment.