-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(TestNotificationConfigMenu): left-over controllers + TestRenameEn…
…try(page DONE)[POST requests]
- Loading branch information
1 parent
c4953e8
commit ec2bd2b
Showing
9 changed files
with
640 additions
and
45 deletions.
There are no files selected for viewing
383 changes: 341 additions & 42 deletions
383
frontend/src/components/admin/testManagementConfigMenu/TestRenameEntry.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...a/org/openelisglobal/common/management/controller/rest/PanelManagementRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.openelisglobal.common.management.controller.rest; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import org.openelisglobal.common.controller.BaseController; | ||
import org.openelisglobal.common.management.form.PanelManagementForm; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/rest") | ||
public class PanelManagementRestController extends BaseController { | ||
|
||
@RequestMapping(value = "/PanelManagement", method = { RequestMethod.GET, RequestMethod.POST }) | ||
public PanelManagementForm showPanelManagement(HttpServletRequest request) { | ||
PanelManagementForm form = new PanelManagementForm(); | ||
|
||
// return findForward(FWD_SUCCESS, form); | ||
return form; | ||
} | ||
|
||
@Override | ||
protected String findLocalForward(String forward) { | ||
if (FWD_SUCCESS.equals(forward)) { | ||
return "panelManagementDefinition"; | ||
} else { | ||
return "PageNotFound"; | ||
} | ||
} | ||
|
||
@Override | ||
protected String getPageTitleKey() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected String getPageSubtitleKey() { | ||
return null; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
.../openelisglobal/common/management/controller/rest/SampleTypeManagementRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.openelisglobal.common.management.controller.rest; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import org.openelisglobal.common.controller.BaseController; | ||
import org.openelisglobal.common.management.form.SampleTypeManagementForm; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/rest") | ||
public class SampleTypeManagementRestController extends BaseController { | ||
|
||
@RequestMapping(value = "/SampleTypeManagement", method = { RequestMethod.GET, RequestMethod.POST }) | ||
public SampleTypeManagementForm showSampleTypeManagement(HttpServletRequest request) { | ||
SampleTypeManagementForm form = new SampleTypeManagementForm(); | ||
// return findForward(FWD_SUCCESS, form); | ||
return form; | ||
} | ||
|
||
@Override | ||
protected String findLocalForward(String forward) { | ||
if (FWD_SUCCESS.equals(forward)) { | ||
return "sampleTypeManagementDefinition"; | ||
} else { | ||
return "PageNotFound"; | ||
} | ||
} | ||
|
||
@Override | ||
protected String getPageTitleKey() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected String getPageSubtitleKey() { | ||
return null; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...openelisglobal/common/management/controller/rest/TestSectionManagementRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.openelisglobal.common.management.controller.rest; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import org.openelisglobal.common.controller.BaseController; | ||
import org.openelisglobal.common.management.form.TestSectionManagementForm; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/rest") | ||
public class TestSectionManagementRestController extends BaseController { | ||
|
||
@RequestMapping(value = "/TestSectionManagement", method = { RequestMethod.GET, RequestMethod.POST }) | ||
public TestSectionManagementForm showTestSectionManagement(HttpServletRequest request) { | ||
TestSectionManagementForm form = new TestSectionManagementForm(); | ||
|
||
// return findForward(FWD_SUCCESS, form); | ||
return form; | ||
} | ||
|
||
@Override | ||
protected String findLocalForward(String forward) { | ||
if (FWD_SUCCESS.equals(forward)) { | ||
return "testSectionManagementDefinition"; | ||
} else { | ||
return "PageNotFound"; | ||
} | ||
} | ||
|
||
@Override | ||
protected String getPageTitleKey() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected String getPageSubtitleKey() { | ||
return null; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...ava/org/openelisglobal/common/management/controller/rest/UomManagementRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.openelisglobal.common.management.controller.rest; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import org.openelisglobal.common.controller.BaseController; | ||
import org.openelisglobal.common.management.form.UomManagementForm; | ||
import org.springframework.web.bind.WebDataBinder; | ||
import org.springframework.web.bind.annotation.InitBinder; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/rest") | ||
public class UomManagementRestController extends BaseController { | ||
|
||
private static final String[] ALLOWED_FIELDS = new String[] {}; | ||
|
||
@InitBinder | ||
public void initBinder(WebDataBinder binder) { | ||
binder.setAllowedFields(ALLOWED_FIELDS); | ||
} | ||
|
||
@RequestMapping(value = "/UomManagement", method = { RequestMethod.GET, RequestMethod.POST }) | ||
public UomManagementForm showUomManagement(HttpServletRequest request) { | ||
UomManagementForm form = new UomManagementForm(); | ||
|
||
// return findForward(FWD_SUCCESS, form); | ||
return form; | ||
} | ||
|
||
@Override | ||
protected String findLocalForward(String forward) { | ||
if (FWD_SUCCESS.equals(forward)) { | ||
return "uomManagementDefinition"; | ||
} else { | ||
return "PageNotFound"; | ||
} | ||
} | ||
|
||
@Override | ||
protected String getPageTitleKey() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected String getPageSubtitleKey() { | ||
return null; | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
...n/java/org/openelisglobal/common/provider/query/rest/TestNamesProviderRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* The contents of this file are subject to the Mozilla Public License | ||
* Version 1.1 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* http://www.mozilla.org/MPL/ | ||
* | ||
* Software distributed under the License is distributed on an "AS IS" | ||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing rights and limitations under | ||
* the License. | ||
* | ||
* The Original Code is OpenELIS code. | ||
* | ||
* Copyright (C) ITECH, University of Washington, Seattle WA. All Rights Reserved. | ||
*/ | ||
package org.openelisglobal.common.provider.query.rest; | ||
|
||
import java.util.Locale; | ||
import org.apache.commons.validator.GenericValidator; | ||
import org.json.simple.JSONObject; | ||
import org.openelisglobal.common.log.LogEvent; | ||
import org.openelisglobal.localization.valueholder.Localization; | ||
import org.openelisglobal.spring.util.SpringContext; | ||
import org.openelisglobal.test.service.TestService; | ||
import org.openelisglobal.test.valueholder.Test; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/rest") | ||
public class TestNamesProviderRestController { | ||
|
||
private final TestService testService; | ||
|
||
public TestNamesProviderRestController(TestService testService) { | ||
this.testService = testService; | ||
} | ||
|
||
@GetMapping("/TestNamesProvider") | ||
public ResponseEntity<JSONObject> processRequest(@RequestParam("testId") String testId) { | ||
|
||
String jResult; | ||
JSONObject jsonResult = new JSONObject(); | ||
String jString; | ||
|
||
if (GenericValidator.isBlankOrNull(testId)) { | ||
jResult = "INVALID"; | ||
jString = "Internal error, please contact Admin and file bug report"; | ||
return ResponseEntity.badRequest().body(createErrorResponse(jString)); | ||
} else { | ||
try { | ||
jResult = createJsonTestNames(testId, jsonResult); | ||
jString = jsonResult.toJSONString(); | ||
} catch (IllegalStateException e) { | ||
LogEvent.logDebug(e); | ||
jResult = "INVALID"; | ||
jString = "Internal error, please contact Admin and file bug report"; | ||
return ResponseEntity.status(500).body(createErrorResponse(jString)); | ||
} | ||
} | ||
return ResponseEntity.ok(jsonResult); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private String createJsonTestNames(String testId, JSONObject jsonResult) throws IllegalStateException { | ||
|
||
String INVALID = "invalid"; | ||
String VALID = "valid"; | ||
|
||
if (GenericValidator.isBlankOrNull(testId)) { | ||
throw new IllegalStateException("TestNamesProvider testId was blank. It must have a value"); | ||
} | ||
|
||
Test test = SpringContext.getBean(TestService.class).get(testId); | ||
if (test != null) { | ||
Localization nameLocalization = test.getLocalizedTestName(); | ||
Localization reportNameLocalization = test.getLocalizedReportingName(); | ||
|
||
JSONObject nameObject = new JSONObject(); | ||
addAllLocalizations(nameObject, nameLocalization); | ||
// nameObject.put("english", nameLocalization.getEnglish()); | ||
// nameObject.put("french", nameLocalization.getFrench()); | ||
jsonResult.put("name", nameObject); | ||
|
||
JSONObject reportingNameObject = new JSONObject(); | ||
addAllLocalizations(reportingNameObject, reportNameLocalization); | ||
// reportingNameObject.put("english", reportNameLocalization.getEnglish()); | ||
// reportingNameObject.put("french", reportNameLocalization.getFrench()); | ||
jsonResult.put("reportingName", reportingNameObject); | ||
|
||
return VALID; | ||
} | ||
|
||
return INVALID; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private void addAllLocalizations(JSONObject jsonObject, Localization localization) { | ||
for (Locale locale : localization.getLocalesWithValue()) { | ||
jsonObject.put(locale.getDisplayLanguage(Locale.ENGLISH).toLowerCase(), | ||
localization.getLocalizedValue(locale)); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private JSONObject createErrorResponse(String message) { | ||
JSONObject errorResponse = new JSONObject(); | ||
errorResponse.put("status", "error"); | ||
errorResponse.put("message", message); | ||
return errorResponse; | ||
} | ||
} |