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) The Minnesota Department of Health. All Rights Reserved.
- */
-package org.openelisglobal.common.provider.reports;
-
-import java.io.IOException;
-import java.util.Map;
-import javax.print.Doc;
-import javax.print.DocFlavor;
-import javax.print.DocPrintJob;
-import javax.print.PrintException;
-import javax.print.PrintService;
-import javax.print.PrintServiceLookup;
-import javax.print.SimpleDoc;
-import javax.print.attribute.HashPrintRequestAttributeSet;
-import javax.print.attribute.PrintRequestAttributeSet;
-import javax.print.attribute.standard.Copies;
-import javax.print.attribute.standard.PrinterName;
-import javax.print.event.PrintJobEvent;
-import javax.print.event.PrintJobListener;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.openelisglobal.common.exception.LIMSInvalidPrinterException;
-import org.openelisglobal.common.exception.LIMSPrintException;
-import org.openelisglobal.common.exception.LIMSRuntimeException;
-import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
-
-/**
- * @author benzd1 modified for bugzilla 2380
- */
-public class SampleLabelPrintProvider extends BasePrintProvider {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.openelisglobal.common.provider.reports.BaseReportsProvider#processRequest
- * (java.util.Map, javax.servlet.http.HttpServletRequest,
- * javax.servlet.http.HttpServletResponse) bugzilla 2380: this method now throws
- * exceptions instead of returning boolean successful
- */
- @Override
- public void processRequest(Map parameters, HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException, PrintException, LIMSPrintException, LIMSInvalidPrinterException {
-
- try {
-
- PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
- String printer = null;
- PrinterName printerName = null;
-
- PrintService ps = null;
-
- // bugzilla 2380
- String validPrintersMessage = "";
- for (int i = 0; i < services.length; i++) {
- printer = services[i].getName();
- // LogEvent.logInfo(this.getClass().getSimpleName(), "method unkown", "This is
- // one of
- // the printers " + printer);
- // bugzilla 2380 this is for error message to list valid printers in ActionError
- if (i == 0) {
- validPrintersMessage = "\\n";
- }
- validPrintersMessage += "\\n " + printer;
-
- // bugzilla 2380: name must match - not start with
- if (printer.equalsIgnoreCase(SystemConfiguration.getInstance().getLabelPrinterName())) {
- printerName = new PrinterName(printer, null);
- // LogEvent.logInfo(this.getClass().getSimpleName(), "method unkown", "This is
- // the
- // printer I will use "
- // + printerName);
- ps = services[i];
- // bugzilla 2380: load all valid printer names for error message
- // break;
- }
- }
-
- // LogEvent.logInfo(this.getClass().getSimpleName(), "method unkown", "Printer
- // is
- // found " + printer);
- if (printerName == null) {
- throw new LIMSInvalidPrinterException(validPrintersMessage);
- }
-
- String numberOfLabelCopiesString = null;
- int numberOfLabelCopies = 1;
- try {
- numberOfLabelCopiesString = SystemConfiguration.getInstance()
- .getLabelNumberOfCopies("print.label.numberofcopies");
- numberOfLabelCopies = Integer.parseInt(numberOfLabelCopiesString);
- } catch (NumberFormatException e) {
- // bugzilla 2154
- LogEvent.logError(e);
- }
-
- String accessionNumber = (String) parameters.get("Accession_Number");
-
- if (ps == null) {
- throw new LIMSPrintException("no print service");
- }
-
- DocPrintJob job = ps.createPrintJob();
-
- PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
- aset.add(new Copies(numberOfLabelCopies));
-
- String label = SystemConfiguration.getInstance().getDefaultSampleLabel(accessionNumber);
-
- byte[] byt = label.getBytes();
- DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
-
- Doc doc = new SimpleDoc(byt, flavor, null);
-
- job.addPrintJobListener(new MyPrintJobListener());
-
- job.print(doc, aset);
-
- } catch (RuntimeException e) {
- LogEvent.logError(e);
- throw new LIMSRuntimeException("Error in SampleLabelPrintProvider processRequest()", e);
- }
- }
-
- class MyPrintJobListener implements PrintJobListener {
- @Override
- public void printDataTransferCompleted(PrintJobEvent pje) {
- // System.out
- // .println("The print data has been transferred to the print service");
- }
-
- @Override
- public void printJobCanceled(PrintJobEvent pje) {
- // LogEvent.logInfo(this.getClass().getSimpleName(), "method unkown", "The print
- // job
- // was cancelled");
- }
-
- @Override
- public void printJobCompleted(PrintJobEvent pje) {
- // LogEvent.logInfo(this.getClass().getSimpleName(), "method unkown", "The print
- // job
- // was completed");
- }
-
- @Override
- public void printJobFailed(PrintJobEvent pje) {
- // LogEvent.logInfo(this.getClass().getSimpleName(), "method unkown", "The print
- // job
- // has failed");
- }
-
- @Override
- public void printJobNoMoreEvents(PrintJobEvent pje) {
- // System.out
- // .println("No more events will be delivered from this print service for this
- // print job.");
- // No more events will be delivered from this
- // print service for this print job.
- // This event is fired in cases where the print service
- // is not able to determine when the job completes.
- }
-
- @Override
- public void printJobRequiresAttention(PrintJobEvent pje) {
- // System.out
- // .println("The print service requires some attention to repair some problem.
- // E.g. running out of paper would");
- // The print service requires some attention to repair
- // some problem. E.g. running out of paper would
- // cause this event to be fired.
- }
- }
-}
diff --git a/src/main/java/org/openelisglobal/common/provider/selectdropdown/TestAnalyteTestResultSelectDropDownProvider.java b/src/main/java/org/openelisglobal/common/provider/selectdropdown/TestAnalyteTestResultSelectDropDownProvider.java
index b9a8bfbcc9..c29147feca 100644
--- a/src/main/java/org/openelisglobal/common/provider/selectdropdown/TestAnalyteTestResultSelectDropDownProvider.java
+++ b/src/main/java/org/openelisglobal/common/provider/selectdropdown/TestAnalyteTestResultSelectDropDownProvider.java
@@ -20,8 +20,8 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.dictionary.service.DictionaryService;
import org.openelisglobal.dictionary.valueholder.Dictionary;
import org.openelisglobal.spring.util.SpringContext;
@@ -95,7 +95,8 @@ public List processRequest(HttpServletRequest request, HttpServletResponse respo
for (int i = 0; i < listOfTestResults.size(); i++) {
TestResult tr = new TestResult();
tr = (TestResult) listOfTestResults.get(i);
- if (tr.getTestResultType().equals(SystemConfiguration.getInstance().getDictionaryType())) {
+ if (tr.getTestResultType()
+ .equals(ConfigurationProperties.getInstance().getPropertyValue("dictionaryType"))) {
// get from dictionary
Dictionary dictionary = new Dictionary();
dictionary.setId(tr.getValue());
diff --git a/src/main/java/org/openelisglobal/common/provider/validation/AccessionNumberValidationProvider.java b/src/main/java/org/openelisglobal/common/provider/validation/AccessionNumberValidationProvider.java
index 47cde74430..b64a377075 100644
--- a/src/main/java/org/openelisglobal/common/provider/validation/AccessionNumberValidationProvider.java
+++ b/src/main/java/org/openelisglobal/common/provider/validation/AccessionNumberValidationProvider.java
@@ -20,8 +20,8 @@
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
import org.openelisglobal.common.servlet.validation.AjaxServlet;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.sample.service.SampleService;
import org.openelisglobal.sample.valueholder.Sample;
import org.openelisglobal.spring.util.SpringContext;
@@ -75,8 +75,8 @@ public String validate(String targetId, String form) throws LIMSRuntimeException
if (form.equalsIgnoreCase("humanSampleOneForm")) {
// bugzilla 1581 handle null status
if (!StringUtil.isNullorNill(sample.getStatus())) {
- if (!sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusQuickEntryComplete())) {
+ if (!sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.quick.entry.complete"))) {
retVal = INVALID;
}
} else {
@@ -85,8 +85,8 @@ public String validate(String targetId, String form) throws LIMSRuntimeException
} else if (form.equalsIgnoreCase("humanSampleTwoForm")) {
// bugzilla 1581 handle null status
if (!StringUtil.isNullorNill(sample.getStatus())) {
- if (!sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusEntry1Complete())) {
+ if (!sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.entry.1.complete"))) {
retVal = INVALID;
}
} else {
@@ -97,9 +97,10 @@ public String validate(String targetId, String form) throws LIMSRuntimeException
} else if (form.equalsIgnoreCase("influenzaSampleXMLBySampleForm")) {
if (!StringUtil.isNullorNill(sample.getStatus())) {
if (!sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusEntry2Complete())
- && !sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusReleased())) {
+ .equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.entry.2.complete"))
+ && !sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.released"))) {
retVal = INVALIDSTATUS;
}
@@ -108,8 +109,8 @@ public String validate(String targetId, String form) throws LIMSRuntimeException
}
} else if (form.equalsIgnoreCase("testManagementForm")) {
if (!StringUtil.isNullorNill(sample.getStatus())) {
- if (sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusLabelPrinted())) {
+ if (sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.label.printed"))) {
retVal = INVALIDSTATUS;
}
} else {
@@ -119,8 +120,8 @@ public String validate(String targetId, String form) throws LIMSRuntimeException
// bugzilla 2513
} else if (form.equalsIgnoreCase("resultsEntryForm")) {
if (!StringUtil.isNullorNill(sample.getStatus())) {
- if (sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusLabelPrinted())) {
+ if (sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.label.printed"))) {
retVal = INVALIDSTATUS;
}
@@ -134,17 +135,19 @@ else if (form.equalsIgnoreCase("batchResultsVerificationForm")) {
// for human (clinical) we require demographics to be available at time of
// results verification
if (sample.getDomain() != null
- && sample.getDomain().equals(SystemConfiguration.getInstance().getHumanDomain())
- && !sample.getStatus().equals(
- SystemConfiguration.getInstance().getSampleStatusEntry2Complete())) {
+ && sample.getDomain().equals(
+ ConfigurationProperties.getInstance().getPropertyValue("domain.human"))
+ && !sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.entry.2.complete"))) {
retVal = INVALIDSTATUS;
}
// for newborn (and possibly other domains) allow verification of sample results
// even after quick entry
if (sample.getDomain() != null
- && !sample.getDomain().equals(SystemConfiguration.getInstance().getHumanDomain())
- && sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusLabelPrinted())) {
+ && !sample.getDomain().equals(
+ ConfigurationProperties.getInstance().getPropertyValue("domain.human"))
+ && sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.label.printed"))) {
retVal = INVALIDSTATUS;
}
} else {
@@ -153,15 +156,15 @@ else if (form.equalsIgnoreCase("batchResultsVerificationForm")) {
// bugzilla 2028
} else if (form.equalsIgnoreCase("qaEventsEntryForm")) {
if (!StringUtil.isNullorNill(sample.getStatus())) {
- if (sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusLabelPrinted())) {
+ if (sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.label.printed"))) {
retVal = INVALIDSTATUS;
// bugzilla 2029
}
} else if (form.equalsIgnoreCase("batchQaEventsEntryForm")) {
if (!StringUtil.isNullorNill(sample.getStatus())) {
- if (sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusLabelPrinted())) {
+ if (sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.label.printed"))) {
retVal = INVALIDSTATUS;
}
}
@@ -171,8 +174,8 @@ else if (form.equalsIgnoreCase("batchResultsVerificationForm")) {
// bugzilla 2529
} else if (form.equalsIgnoreCase("newbornSampleOneForm")) {
if (!StringUtil.isNullorNill(sample.getStatus())) {
- if (!sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusQuickEntryComplete())) {
+ if (!sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.quick.entry.complete"))) {
retVal = INVALIDSTATUS;
}
} else {
@@ -181,8 +184,8 @@ else if (form.equalsIgnoreCase("batchResultsVerificationForm")) {
// bugzilla 2530
} else if (form.equalsIgnoreCase("newbornSampleTwoForm")) {
if (!StringUtil.isNullorNill(sample.getStatus())) {
- if (!sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusEntry1Complete())) {
+ if (!sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.entry.1.complete"))) {
retVal = INVALIDSTATUS;
}
} else {
@@ -191,8 +194,8 @@ else if (form.equalsIgnoreCase("batchResultsVerificationForm")) {
// bugzilla 2531
} else if (form.equalsIgnoreCase("newbornSampleFullForm")) {
if (!StringUtil.isNullorNill(sample.getStatus())) {
- if (!sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusEntry2Complete())) {
+ if (!sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.entry.2.complete"))) {
retVal = INVALIDSTATUS;
}
} else {
@@ -201,8 +204,8 @@ else if (form.equalsIgnoreCase("batchResultsVerificationForm")) {
// bugzilla 2564
} else if (form.equalsIgnoreCase("testManagementNewbornForm")) {
if (!StringUtil.isNullorNill(sample.getStatus())) {
- if (!sample.getStatus()
- .equals(SystemConfiguration.getInstance().getSampleStatusEntry2Complete())) {
+ if (!sample.getStatus().equals(ConfigurationProperties.getInstance()
+ .getPropertyValue("sample.status.entry.2.complete"))) {
retVal = INVALIDSTATUS;
}
} else {
diff --git a/src/main/java/org/openelisglobal/common/rest/DisplayListController.java b/src/main/java/org/openelisglobal/common/rest/DisplayListController.java
index cc763646e7..367ba026cb 100644
--- a/src/main/java/org/openelisglobal/common/rest/DisplayListController.java
+++ b/src/main/java/org/openelisglobal/common/rest/DisplayListController.java
@@ -13,6 +13,7 @@
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.core.util.KeyValuePair;
import org.openelisglobal.common.action.IActionConstants;
import org.openelisglobal.common.constants.Constants;
import org.openelisglobal.common.rest.provider.bean.TestDisplayBean;
@@ -26,7 +27,6 @@
import org.openelisglobal.common.util.DateUtil;
import org.openelisglobal.common.util.IdValuePair;
import org.openelisglobal.common.util.LabelValuePair;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.dictionary.service.DictionaryService;
import org.openelisglobal.dictionary.valueholder.Dictionary;
import org.openelisglobal.localization.service.LocalizationService;
@@ -44,16 +44,22 @@
import org.openelisglobal.siteinformation.service.SiteInformationService;
import org.openelisglobal.siteinformation.valueholder.SiteInformation;
import org.openelisglobal.spring.util.SpringContext;
+import org.openelisglobal.systemuser.controller.UnifiedSystemUserController;
import org.openelisglobal.systemuser.service.UserService;
+import org.openelisglobal.test.service.TestSectionService;
import org.openelisglobal.test.service.TestService;
import org.openelisglobal.test.service.TestServiceImpl;
import org.openelisglobal.test.valueholder.Test;
+import org.openelisglobal.test.valueholder.TestSection;
import org.openelisglobal.testresult.service.TestResultService;
import org.openelisglobal.testresult.valueholder.TestResult;
import org.openelisglobal.typeofsample.service.TypeOfSampleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.ResolvableType;
import org.springframework.http.MediaType;
+import org.springframework.security.oauth2.client.registration.ClientRegistration;
+import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -70,6 +76,9 @@ public class DisplayListController extends BaseRestController {
@Value("${org.itech.login.oauth:false}")
private Boolean useOAUTH;
+ @Value("${org.itech.login.form:true}")
+ private Boolean useFormLogin;
+
@Autowired
private ProviderService providerService;
@@ -88,6 +97,9 @@ public class DisplayListController extends BaseRestController {
@Autowired
TypeOfSampleService typeOfSampleService;
+ @Autowired
+ TestSectionService testSectionService;
+
@Autowired
private LocalizationService localizationService;
@@ -103,6 +115,11 @@ public class DisplayListController extends BaseRestController {
@Autowired
DictionaryService dictionaryService;
+ @Autowired(required = false)
+ private ClientRegistrationRepository clientRegistrationRepository;
+ private static String authorizationRequestBaseUri = "oauth2/authorization";
+ Map oauth2AuthenticationUrls = new HashMap<>();
+
private static boolean HAS_NFS_PANEL = false;
static {
@@ -310,8 +327,8 @@ private List getSiteNameList() {
@GetMapping(value = "configuration-properties", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
- private Map getConfigurationProperties() {
- Map configs = getOpenConfigurationProperties();
+ private Map getConfigurationProperties() {
+ Map configs = getOpenConfigurationProperties();
configs.put(Property.allowResultRejection.toString(),
ConfigurationProperties.getInstance().getPropertyValue(Property.allowResultRejection));
@@ -326,17 +343,16 @@ private Map getConfigurationProperties() {
ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_DATE_LOCALE));
configs.put(Property.UseExternalPatientInfo.toString(),
ConfigurationProperties.getInstance().getPropertyValue(Property.UseExternalPatientInfo));
- configs.put("DEFAULT_PAGE_SIZE", String.valueOf(SystemConfiguration.getInstance().getDefaultPageSize()));
+ configs.put("DEFAULT_PAGE_SIZE",
+ ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
return configs;
}
// these are fetched before login
@GetMapping(value = "open-configuration-properties", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
- private Map getOpenConfigurationProperties() {
- ConfigurationProperties.forceReload();
-
- Map configs = new HashMap<>();
+ private Map getOpenConfigurationProperties() {
+ Map configs = new HashMap<>();
configs.put(Property.restrictFreeTextProviderEntry.toString(),
ConfigurationProperties.getInstance().getPropertyValue(Property.restrictFreeTextProviderEntry));
configs.put(Property.restrictFreeTextRefSiteEntry.toString(),
@@ -359,6 +375,18 @@ private Map getOpenConfigurationProperties() {
configs.put("studyManagementTab", studyManagementTab != null ? studyManagementTab.getValue() : "false");
configs.put("useSaml", useSAML ? "true" : "false");
configs.put("useOauth", useOAUTH ? "true" : "false");
+ if (useOAUTH) {
+ ResolvableType type = ResolvableType.forInstance(clientRegistrationRepository).as(Iterable.class);
+ if (type != ResolvableType.NONE && ClientRegistration.class.isAssignableFrom(type.resolveGenerics()[0])) {
+ @SuppressWarnings("unchecked")
+ Iterable clientRegistrations = (Iterable) clientRegistrationRepository;
+ clientRegistrations.forEach(registration -> oauth2AuthenticationUrls.put(registration.getClientName(),
+ authorizationRequestBaseUri + "/" + registration.getRegistrationId()));
+ }
+ configs.put("oauthUrls",
+ oauth2AuthenticationUrls.entrySet().stream().map(e -> new KeyValuePair(e.getKey(), e.getValue())));
+ }
+ configs.put("useFormLogin", useFormLogin ? "true" : "false");
configs.put(Property.SUBJECT_ON_WORKPLAN.toString(),
ConfigurationProperties.getInstance().getPropertyValue(Property.SUBJECT_ON_WORKPLAN));
configs.put(Property.NEXT_VISIT_DATE_ON_WORKPLAN.toString(),
@@ -557,4 +585,32 @@ public List getRoles(@RequestParam(required = false) String samp
return roleService.getAllActiveRoles().stream().filter(r -> !r.getGroupingRole())
.map(r -> new LabelValuePair(r.getDescription(), r.getName())).collect(Collectors.toList());
}
+
+ @GetMapping(value = "systemroles-testsections", produces = MediaType.APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public List getRolesWithTestSections() {
+ List rolesWithTestSections = new ArrayList<>();
+ String globalParentRoleId = roleService.getRoleByName(Constants.GLOBAL_ROLES_GROUP).getId();
+ String labUnitRoleId = roleService.getRoleByName(Constants.LAB_ROLES_GROUP).getId();
+ List testSections = testSectionService.getAllActiveTestSections();
+
+ List roles = roleService.getAllActiveRoles();
+ List globalRoles = roles.stream().filter(role -> globalParentRoleId.equals(role.getGroupingParent()))
+ .collect(Collectors.toList());
+ List labUnitRoles = roles.stream().filter(role -> labUnitRoleId.equals(role.getGroupingParent()))
+ .collect(Collectors.toList());
+ rolesWithTestSections.addAll(
+ globalRoles.stream().map(r -> new LabelValuePair(r.getDescription(), "oeg-" + r.getName().trim()))
+ .collect(Collectors.toList()));
+
+ rolesWithTestSections.addAll(labUnitRoles.stream()
+ .map(r -> new LabelValuePair(r.getDescription(),
+ "oeg-" + r.getName().trim() + "-" + UnifiedSystemUserController.ALL_LAB_UNITS))
+ .collect(Collectors.toList()));
+ testSections.forEach(e -> rolesWithTestSections.addAll(labUnitRoles.stream()
+ .map(r -> new LabelValuePair(r.getDescription(),
+ "oeg-" + r.getName().trim() + "-" + e.getTestSectionName().trim()))
+ .collect(Collectors.toList())));
+ return rolesWithTestSections;
+ }
}
diff --git a/src/main/java/org/openelisglobal/common/services/DisplayListService.java b/src/main/java/org/openelisglobal/common/services/DisplayListService.java
index e07e7704ad..d1649f99a7 100644
--- a/src/main/java/org/openelisglobal/common/services/DisplayListService.java
+++ b/src/main/java/org/openelisglobal/common/services/DisplayListService.java
@@ -27,11 +27,11 @@
import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.IdValuePair;
import org.openelisglobal.common.util.LocaleChangeListener;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.dictionary.service.DictionaryService;
import org.openelisglobal.dictionary.valueholder.Dictionary;
import org.openelisglobal.gender.service.GenderService;
import org.openelisglobal.gender.valueholder.Gender;
+import org.openelisglobal.internationalization.GlobalLocaleResolver;
import org.openelisglobal.internationalization.MessageUtil;
import org.openelisglobal.method.service.MethodService;
import org.openelisglobal.method.valueholder.Method;
@@ -73,6 +73,7 @@
import org.openelisglobal.unitofmeasure.valueholder.UnitOfMeasure;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.web.servlet.LocaleResolver;
@Service
public class DisplayListService implements LocaleChangeListener {
@@ -134,14 +135,18 @@ public enum ListType {
private ProviderService providerService;
@Autowired
private ProgramService programService;
+ @Autowired
+ private LocaleResolver localeResolver;
@PostConstruct
private void setupGlobalVariables() {
instance = this;
refreshLists();
+ if (localeResolver instanceof GlobalLocaleResolver) {
+ ((GlobalLocaleResolver) localeResolver).addLocalChangeListener(this);
+ }
- SystemConfiguration.getInstance().addLocalChangeListener(this);
}
public static DisplayListService getInstance() {
diff --git a/src/main/java/org/openelisglobal/common/services/LabIdentificationService.java b/src/main/java/org/openelisglobal/common/services/LabIdentificationService.java
index e366277744..adb2c560ef 100644
--- a/src/main/java/org/openelisglobal/common/services/LabIdentificationService.java
+++ b/src/main/java/org/openelisglobal/common/services/LabIdentificationService.java
@@ -16,7 +16,6 @@
import java.util.Locale;
import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.ConfigurationProperties.Property;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.springframework.stereotype.Service;
@Service
@@ -39,6 +38,7 @@ public String getLabPhone() {
}
public Locale getLanguageLocale() {
- return SystemConfiguration.getInstance().getDefaultLocale();
+ return Locale
+ .forLanguageTag(ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE));
}
}
diff --git a/src/main/java/org/openelisglobal/common/util/ConfigurationProperties.java b/src/main/java/org/openelisglobal/common/util/ConfigurationProperties.java
index fba4442642..7728d3aa3c 100644
--- a/src/main/java/org/openelisglobal/common/util/ConfigurationProperties.java
+++ b/src/main/java/org/openelisglobal/common/util/ConfigurationProperties.java
@@ -15,9 +15,8 @@
*/
package org.openelisglobal.common.util;
-import java.util.HashMap;
-import java.util.Map;
import org.apache.commons.validator.GenericValidator;
+import org.openelisglobal.common.util.DefaultConfigurationProperties.OEProperties;
import org.openelisglobal.spring.util.SpringContext;
/*
@@ -26,205 +25,251 @@
*/
public abstract class ConfigurationProperties {
- private static final Object lockObj = new Object();
- private static ConfigurationProperties activeConcreteInstance = null;
- protected Map propertiesValueMap = new HashMap<>();
+ protected OEProperties finalProperties;
// These should all be upper case. As you touch them change them
public enum Property {
- AmbiguousDateValue("date.ambiguous.date.value"), // Are ambiguous dates allowed for DOB. i.e. patient knows age
+ AmbiguousDateValue("date.ambiguous.date.value", "text"), // Are ambiguous dates allowed for DOB. i.e. patient
+ // knows age
// but not actuall DOB
- AmbiguousDateHolder("date.ambiguous.date.holder"), // What character should be used as a placeholder when
+ AmbiguousDateHolder("date.ambiguous.date.holder", "text"), // What character should be used as a placeholder
+ // when
// displaying the date. i.e. if 'X' then XX/XX/2000
- ReferingLabParentOrg("organization.reference.lab.parent"), // Should the parent organization of a lab be
+ ReferingLabParentOrg("organization.reference.lab.parent", "text"), // Should the parent organization of a lab be
// entered. i.e. The hospital in which the lab is run
- FormFieldSet("setFieldForm"), // internal only
- PasswordRequirments("passwordRequirements"), // Indicator for what the password complexity requirements are.
+ FormFieldSet("setFieldForm", "text"), // internal only
+ PasswordRequirments("passwordRequirements", "text"), // Indicator for what the password complexity requirements
+ // are.
// Should be standardized
- StringContext("stringContext"), // Determines which equivalent string should be used. i.e. label for
+ StringContext("stringContext", "text"), // Determines which equivalent string should be used. i.e. label for
// accession
// number can be 'lab number' or 'accession number'
- StatusRules("statusRules"), // Only used to separate RetroCI rules from others. May be obsolete
- SiteCode("siteNumber"), // Code referring to site
- SiteName("SiteName"), // Name for site
- Addressline1label("Address line 1 label"), // The address lines 1 can be used to specify anything
- Addressline2label("Address line 2 label"), // The address lines 2 can be used to specify anything
- Addressline3label("Address line 3 label"), // The address lines 3 can be used to specify anything
- GeographicUnit1Label("Geographic Unit 1 Label"), // The Geographical units for a particular region
- GeographicUnit2Label("Geographic Unit 2 Label"), // The Geographical units for a particular district
- AccessionFormat("acessionFormat"), // Format of accession number can be one of SITEYEARNUM, YEARNUM OR
+ StatusRules("statusRules", "text"), // Only used to separate RetroCI rules from others. May be obsolete
+ SiteCode("siteNumber", "text"), // Code referring to site
+ SiteName("SiteName", "text"), // Name for site
+ Addressline1label("Address line 1 label", "text"), // The address lines 1 can be used to specify anything
+ Addressline2label("Address line 2 label", "text"), // The address lines 2 can be used to specify anything
+ Addressline3label("Address line 3 label", "text"), // The address lines 3 can be used to specify anything
+ GeographicUnit1Label("Geographic Unit 1 Label", "text"), // The Geographical units for a particular region
+ GeographicUnit2Label("Geographic Unit 2 Label", "text"), // The Geographical units for a particular district
+ AccessionFormat("acessionFormat", "text"), // Format of accession number can be one of SITEYEARNUM, YEARNUM OR
// PROGRAMNUM, ALPHANUM see AccessionNumberValidatorFactory
- ReflexAction("reflexAction"), // In combination with flags in reflex table determines actual action,
+ ReflexAction("reflexAction", "text"), // In combination with flags in reflex table determines actual action,
// should be
// standardize
- TrainingInstallation("TrainingInstallation"), // Flag to indicate if this is a training instance
- UseExternalPatientInfo("useExternalPatientSource"), // If true patient information will be searched for
+ TrainingInstallation("TrainingInstallation", "text"), // Flag to indicate if this is a training instance
+ UseExternalPatientInfo("useExternalPatientSource", "text"), // If true patient information will be searched for
// externally
- PatientSearchURL("patientSearchURL"), // URL of where external patient information will be searched
- PatientSearchUserName("patientSearchLogOnUser"), // User name for accesses to external patient search
- PatientSearchPassword("PatientSearchPassword"), // User password for accesses to external patient search
- PatientSearchEnabled("PatientSearchEnabled"), labDirectorName("lab director"), // The name of the lab director
- languageSwitch("allowLanguageChange"), // If true a user can switch between English and French (changes it
+ PatientSearchURL("patientSearchURL", "text"), // URL of where external patient information will be searched
+ PatientSearchUserName("patientSearchLogOnUser", "text"), // User name for accesses to external patient search
+ PatientSearchPassword("PatientSearchPassword", "text"), // User password for accesses to external patient search
+ PatientSearchEnabled("PatientSearchEnabled", "text"), labDirectorName("lab director", "text"), // The name of
+ // the lab
+ // director
+ languageSwitch("allowLanguageChange", "text"), // If true a user can switch between English and French (changes
+ // it
// for
// everybody)
- reportResults("resultReporting"), // If true results will be reported electronically
- resultReportingURL("resultReportingURL"), // URL for electronic result reporting
- malariaSurveillanceReport("malariaSurReport"), // If true malaria surveillance will be reported electronically
- malariaSurveillanceReportURL("malariaSurURL"), // URL for malaria surveillance reporting
- malariaCaseReport("malariaCaseReport"), // If true send malaria case reports
- malariaCaseReportURL("malariaCaseURL"), // URL for malaria case reports
- releaseNumber("releaseNumber"), // The release number
- // buildNumber("buildNumber"), //Repository identifier
- configurationName("configuration name"), // Identifies the configuration i.e. HaitiLNSP or CI IPCI
- testUsageReportingURL("testUsageAggregationUrl"), // URL for test summary reporting
- testUsageReporting("testUsageReporting"), // If true send test summary report electronically
- roleRequiredForModifyResults("modify results role"), // If true a separate role is needed to modify results
- notesRequiredForModifyResults("modify results note required"), // If true a note is required when a result is
+ reportResults("resultReporting", "text"), // If true results will be reported electronically
+ resultReportingURL("resultReportingURL", "text"), // URL for electronic result reporting
+ malariaSurveillanceReport("malariaSurReport", "text"), // If true malaria surveillance will be reported
+ // electronically
+ malariaSurveillanceReportURL("malariaSurURL", "text"), // URL for malaria surveillance reporting
+ malariaCaseReport("malariaCaseReport", "text"), // If true send malaria case reports
+ malariaCaseReportURL("malariaCaseURL", "text"), // URL for malaria case reports
+ releaseNumber("releaseNumber", "text"), // The release number
+ // buildNumber("buildNumber", "text"), //Repository identifier
+ configurationName("configuration name", "text"), // Identifies the configuration i.e. HaitiLNSP or CI IPCI
+ testUsageReportingURL("testUsageAggregationUrl", "text"), // URL for test summary reporting
+ testUsageReporting("testUsageReporting", "text"), // If true send test summary report electronically
+ roleRequiredForModifyResults("modify results role", "text"), // If true a separate role is needed to modify
+ // results
+ notesRequiredForModifyResults("modify results note required", "text"), // If true a note is required when a
+ // result is
// modified
- resultTechnicianName("ResultTechnicianName"), // If true the technicians name is needed for results
- customCriticalMessage("customCriticalMessage"), // Override the default message for a critical result
- allowResultRejection("allowResultRejection"), // If true then a technician has the ability to reject an
+ resultTechnicianName("ResultTechnicianName", "text"), // If true the technicians name is needed for results
+ customCriticalMessage("customCriticalMessage", "text"), // Override the default message for a critical result
+ allowResultRejection("allowResultRejection", "text"), // If true then a technician has the ability to reject an
// individual test and select a reason for rejection
- restrictFreeTextRefSiteEntry("restrictFreeTextRefSiteEntry"), // If true then a user cannot enter new referring
+ restrictFreeTextRefSiteEntry("restrictFreeTextRefSiteEntry", "text"), // If true then a user cannot enter new
+ // referring
// sites during sample entry and must choose from
// list provided
- restrictFreeTextMethodEntry("restrictFreeTextMethodEntry"), // If true the user must choose an existing method
+ restrictFreeTextMethodEntry("restrictFreeTextMethodEntry", "text"), // If true the user must choose an existing
+ // method
// and will not be able to create a new method
// through result entry
- restrictFreeTextProviderEntry("restrictFreeTextProviderEntry"), // If true then a user cannot enter new
+ restrictFreeTextProviderEntry("restrictFreeTextProviderEntry", "text"), // If true then a user cannot enter new
// providers during sample entry and must choose
// from list provided
- autoFillTechNameBox("autoFillTechNameBox"), // If true a box will be provided to auto-fill technicians name for
+ autoFillTechNameBox("autoFillTechNameBox", "text"), // If true a box will be provided to auto-fill technicians
+ // name for
// all results on page
- autoFillTechNameUser("autoFillTechNameUser"), // If true the technicians name will be auto-filled with the name
+ autoFillTechNameUser("autoFillTechNameUser", "text"), // If true the technicians name will be auto-filled with
+ // the name
// of the logged in user
- AUTOFILL_COLLECTION_DATE("auto-fill collection date/time"), // If true the collection date will be auto-filled
+ AUTOFILL_COLLECTION_DATE("auto-fill collection date/time", "text"), // If true the collection date will be
+ // auto-filled
// with current date
- failedValidationMarker("showValidationFailureIcon"), // If true results that failed validation will have icon
+ failedValidationMarker("showValidationFailureIcon", "text"), // If true results that failed validation will have
+ // icon
// next to them
- resultsResendTime("results.send.retry.time"), // How much time between trying to resend results that failed to
+ resultsResendTime("results.send.retry.time", "text"), // How much time between trying to resend results that
+ // failed to
// reach their destination
- TRACK_PATIENT_PAYMENT("trackPayment"), // If true then patient payment status can be entered
- ACCESSION_NUMBER_VALIDATE("validateAccessionNumber"), // If true then validate the accession number
- ALERT_FOR_INVALID_RESULTS("alertWhenInvalidResult"), // If true then technician will get an alert for results
+ TRACK_PATIENT_PAYMENT("trackPayment", "text"), // If true then patient payment status can be entered
+ ACCESSION_NUMBER_VALIDATE("validateAccessionNumber", "text"), // If true then validate the accession number
+ ALERT_FOR_INVALID_RESULTS("alertWhenInvalidResult", "text"), // If true then technician will get an alert for
+ // results
// outside of the valid range
- DEFAULT_LANG_LOCALE("default language locale"), // Default language locale
- DEFAULT_DATE_LOCALE("default date locale"), // Date local
- CONDENSE_NFS_PANEL("condenseNFS"), // Flag used for RetroCI to condense NFS panel tests
- PATIENT_DATA_ON_RESULTS_BY_ROLE("roleForPatientOnResults"), // If true patient data will show on results page
+ DEFAULT_LANG_LOCALE("default language locale", "text"), // Default language locale
+ DEFAULT_DATE_LOCALE("default date locale", "text"), // Date local
+ CONDENSE_NFS_PANEL("condenseNFS", "text"), // Flag used for RetroCI to condense NFS panel tests
+ PATIENT_DATA_ON_RESULTS_BY_ROLE("roleForPatientOnResults", "text"), // If true patient data will show on results
+ // page
// only if user has correct permissions
- USE_PAGE_NUMBERS_ON_REPORTS("reportPageNumbers"), // If true page numbers will be used on reports
- QA_SORT_EVENT_LIST("sortQaEvents"), // If true QA events will be sorted by name
- ALWAYS_VALIDATE_RESULTS("validate all results"), // If true all results will be validated, otherwise just those
+ USE_PAGE_NUMBERS_ON_REPORTS("reportPageNumbers", "text"), // If true page numbers will be used on reports
+ QA_SORT_EVENT_LIST("sortQaEvents", "text"), // If true QA events will be sorted by name
+ ALWAYS_VALIDATE_RESULTS("validate all results", "text"), // If true all results will be validated, otherwise
+ // just those
// outside of valid range and those flagged
- ADDITIONAL_SITE_INFO("additional site info"), // Extra site info for report header
- SUBJECT_ON_WORKPLAN("subject on workplan"), // If true the subject will be on the workplan
- NEXT_VISIT_DATE_ON_WORKPLAN("next visit on workplan"), // If true the next visit date will be on workplan
- RESULTS_ON_WORKPLAN("results on workplan"), // If true a space will be left for results on the workplan
- ACCEPT_EXTERNAL_ORDERS("external orders"), // If true EMR's can make electronic orders to lab
- SIGNATURES_ON_NONCONFORMITY_REPORTS("non-conformity signature"), // If true a space should be left for
+ ADDITIONAL_SITE_INFO("additional site info", "text"), // Extra site info for report header
+ SUBJECT_ON_WORKPLAN("subject on workplan", "text"), // If true the subject will be on the workplan
+ NEXT_VISIT_DATE_ON_WORKPLAN("next visit on workplan", "text"), // If true the next visit date will be on
+ // workplan
+ RESULTS_ON_WORKPLAN("results on workplan", "text"), // If true a space will be left for results on the workplan
+ ACCEPT_EXTERNAL_ORDERS("external orders", "text"), // If true EMR's can make electronic orders to lab
+ SIGNATURES_ON_NONCONFORMITY_REPORTS("non-conformity signature", "text"), // If true a space should be left for
// signatures on non-conformity reports
- NONCONFORMITY_RECEPTION_AS_UNIT("Reception as unit"), // If true then reception will be an option for where a
+ NONCONFORMITY_RECEPTION_AS_UNIT("Reception as unit", "text"), // If true then reception will be an option for
+ // where a
// non-conformity was identified
- NONCONFORMITY_SAMPLE_COLLECTION_AS_UNIT("Collection as unit"), // If true then sample collection will be an
+ NONCONFORMITY_SAMPLE_COLLECTION_AS_UNIT("Collection as unit", "text"), // If true then sample collection will be
+ // an
// option for where a non-conformity was
// identified
- ACCESSION_NUMBER_PREFIX("Accession number prefix"), // If SITEYEARNUM is the format then this is the prefix
- NOTE_EXTERNAL_ONLY_FOR_VALIDATION("validationOnlyNotesAreExternal"), // If true then only validation notes will
+ ACCESSION_NUMBER_PREFIX("Accession number prefix", "text"), // If SITEYEARNUM is the format then this is the
+ // prefix
+ NOTE_EXTERNAL_ONLY_FOR_VALIDATION("validationOnlyNotesAreExternal", "text"), // If true then only validation
+ // notes will
// be on patient report
- PHONE_FORMAT("phone format"), // Format of phone number
- VALIDATE_PHONE_FORMAT("validate phone format"), // If true then entered phone numbers will be validated against
+ PHONE_FORMAT("phone format", "text"), // Format of phone number
+ VALIDATE_PHONE_FORMAT("validate phone format", "text"), // If true then entered phone numbers will be validated
+ // against
// format
- ALLOW_DUPLICATE_SUBJECT_NUMBERS("Allow duplicate subject number"), // If true then duplicate subject numbers are
+ ALLOW_DUPLICATE_SUBJECT_NUMBERS("Allow duplicate subject number", "text"), // If true then duplicate subject
+ // numbers are
// allowed
- ALLOW_DUPLICATE_NATIONAL_IDS("Allow duplicate national ids"), // If true then duplicate national ids are allowed
- VALIDATE_REJECTED_TESTS("validateTechnicalRejection"), // If true then if the technician rejects a test the next
+ ALLOW_DUPLICATE_NATIONAL_IDS("Allow duplicate national ids", "text"), // If true then duplicate national ids are
+ // allowed
+ VALIDATE_REJECTED_TESTS("validateTechnicalRejection", "text"), // If true then if the technician rejects a test
+ // the next
// step is validation
- TEST_NAME_AUGMENTED("augmentTestNameWithType"), // If true then in some places the test name will be suffixed
+ TEST_NAME_AUGMENTED("augmentTestNameWithType", "text"), // If true then in some places the test name will be
+ // suffixed
// with the sample type
- USE_BILLING_REFERENCE_NUMBER("billingRefNumber"), // If true then the user can enter billing codes for latter
+ USE_BILLING_REFERENCE_NUMBER("billingRefNumber", "text"), // If true then the user can enter billing codes for
+ // latter
// reporting
- BILLING_REFERENCE_NUMBER_LABEL("billingRefNumberLocalization"), // The label being used for the billing
+ BILLING_REFERENCE_NUMBER_LABEL("billingRefNumberLocalization", "localization"), // The label being used for the
+ // billing
// reference number
- ORDER_PROGRAM("Program"), // Should program be part of an order
- BANNER_TEXT("bannerHeading"), // Text on Banner
- CLOCK_24("24 hour clock"), // True for 24 hour clock, false for 12 hour clock
- PATIENT_NATIONALITY("supportPatientNationality"), // True if patient nationality should be collected with
+ ORDER_PROGRAM("Program", "text"), // Should program be part of an order
+ BANNER_TEXT("bannerHeading", "localization"), // Text on Banner
+ CLOCK_24("24 hour clock", "text"), // True for 24 hour clock, false for 12 hour clock
+ PATIENT_NATIONALITY("supportPatientNationality", "text"), // True if patient nationality should be collected
+ // with
// patient information
- PATIENT_ID_REQUIRED("Patient ID required"), // True if patient id is required for new patient
- PATIENT_SUBJECT_NUMBER_REQUIRED("Subject number required"), // True if patient subject number is required for
+ PATIENT_ID_REQUIRED("Patient ID required", "text"), // True if patient id is required for new patient
+ PATIENT_SUBJECT_NUMBER_REQUIRED("Subject number required", "text"), // True if patient subject number is
+ // required for
// new patient
- PATIENT_NATIONAL_ID_REQUIRED("National ID required"), // True if patient national id is required for new patient
- QA_SAMPLE_ID_REQUIRED("sample id required"), // True if sample id required from referring lab
- MAX_ORDER_PRINTED("numMaxOrderLabels"), // Max number of order labels that can be printed
- MAX_SPECIMEN_PRINTED("numMaxSpecimenLabels"), // Max number of specimen labels that can be printed
- MAX_ALIQUOT_PRINTED("numMaxAliquotLabels"), // Max number of aliquots that can be printed
- DEFAULT_ORDER_PRINTED("numDefaultOrderLabels"), // Max number of order labels that can be printed
- DEFAULT_SPECIMEN_PRINTED("numDefaultSpecimenLabels"), // Max number of specimen labels that can be printed
- DEFAULT_ALIQUOT_PRINTED("numDefaultAliquotLabels"), // Max number of aliquots that can be printed
- ORDER_BARCODE_HEIGHT("heightOrderLabels"), // Height of the order barcode
- ORDER_BARCODE_WIDTH("widthOrderLabels"), // Width of the order barcode
- SPECIMEN_BARCODE_HEIGHT("heightSpecimenLabels"), // Height of the specimen barcode
- SPECIMEN_BARCODE_WIDTH("widthSpecimenLabels"), // Width of the specimen barcode
- SPECIMEN_FIELD_DATE("collectionDateCheck"), //
- SPECIMEN_FIELD_SEX("patientSexCheck"), //
- SPECIMEN_FIELD_COLLECTED_BY("collectedByCheck"), SPECIMEN_FIELD_TESTS("testsCheck"), //
- BLOCK_BARCODE_HEIGHT("heightBlockLabels"), //
- BLOCK_BARCODE_WIDTH("widthBlockLabels"), //
- SLIDE_BARCODE_HEIGHT("heightSlideLabels"), //
- SLIDE_BARCODE_WIDTH("widthSlideLabels"), //
- ALT_ACCESSION_PREFIX("prePrintAltAccessionPrefix"), //
- USE_ALT_ACCESSION_PREFIX("prePrintUseAltAccession"), //
- USE_ALPHANUM_ACCESSION_PREFIX("useAlphanumAccessionPrefix"), //
- ALPHANUM_ACCESSION_PREFIX("alphanumAccessionPrefix"), //
- LAB_DIRECTOR_NAME("labDirectorName"), //
- LAB_DIRECTOR_TITLE("labDirectorTitle"), //
- INFO_HIGHWAY_USERNAME("infoHighway.username"), //
- INFO_HIGHWAY_PASSWORD("infoHighway.password"), //
- INFO_HIGHWAY_ADDRESS("infoHighway.uri"), //
- INFO_HIGHWAY_ENABLED("infoHighway.enabled"), //
- PATIENT_RESULTS_BMP_SMS_USERNAME("patientresultsbmpsms.username"), //
- PATIENT_RESULTS_BMP_SMS_PASSWORD("patientresultsbmpsms.password"), //
- PATIENT_RESULTS_BMP_SMS_ADDRESS("patientresultsbmpsms.uri"), //
- PATIENT_RESULTS_BMP_SMS_ENABLED("patientresultsbmpsms.enabled"), //
- PATIENT_RESULTS_SMPP_SMS_USERNAME("patientresultssmpp.username"), //
- PATIENT_RESULTS_SMPP_SMS_PASSWORD("patientresultssmpp.password"), //
- PATIENT_RESULTS_SMPP_SMS_ADDRESS("patientresultssmpp.uri"), //
- PATIENT_RESULTS_SMPP_SMS_ENABLED("patientresultssmpp.enabled"), //
- PATIENT_RESULTS_SMTP_USERNAME("patientresultssmtp.username"), //
- PATIENT_RESULTS_SMTP_PASSWORD("patientresultssmtp.password"), //
- PATIENT_RESULTS_SMTP_ADDRESS("patientresultssmtp.uri"), //
- PATIENT_RESULTS_SMTP_ENABLED("patientresultssmtp.enabled"), //
- CONTACT_TRACING("contactTracingEnabled"), //
- REQUIRE_LAB_UNIT_AT_LOGIN("requireLabUnitAtLogin"), //
- ENABLE_CLIENT_REGISTRY("enableClientRegistry"); // if true, then client registry search option is visible on
- // the ui
+ PATIENT_NATIONAL_ID_REQUIRED("National ID required", "text"), // True if patient national id is required for new
+ // patient
+ QA_SAMPLE_ID_REQUIRED("sample id required", "text"), // True if sample id required from referring lab
+ MAX_ORDER_PRINTED("numMaxOrderLabels", "text"), // Max number of order labels that can be printed
+ MAX_SPECIMEN_PRINTED("numMaxSpecimenLabels", "text"), // Max number of specimen labels that can be printed
+ MAX_ALIQUOT_PRINTED("numMaxAliquotLabels", "text"), // Max number of aliquots that can be printed
+ DEFAULT_ORDER_PRINTED("numDefaultOrderLabels", "text"), // Max number of order labels that can be printed
+ DEFAULT_SPECIMEN_PRINTED("numDefaultSpecimenLabels", "text"), // Max number of specimen labels that can be
+ // printed
+ DEFAULT_ALIQUOT_PRINTED("numDefaultAliquotLabels", "text"), // Max number of aliquots that can be printed
+ ORDER_BARCODE_HEIGHT("heightOrderLabels", "text"), // Height of the order barcode
+ ORDER_BARCODE_WIDTH("widthOrderLabels", "text"), // Width of the order barcode
+ SPECIMEN_BARCODE_HEIGHT("heightSpecimenLabels", "text"), // Height of the specimen barcode
+ SPECIMEN_BARCODE_WIDTH("widthSpecimenLabels", "text"), // Width of the specimen barcode
+ SPECIMEN_FIELD_DATE("collectionDateCheck", "text"), //
+ SPECIMEN_FIELD_SEX("patientSexCheck", "text"), //
+ SPECIMEN_FIELD_COLLECTED_BY("collectedByCheck", "text"), SPECIMEN_FIELD_TESTS("testsCheck", "text"), //
+ BLOCK_BARCODE_HEIGHT("heightBlockLabels", "text"), //
+ BLOCK_BARCODE_WIDTH("widthBlockLabels", "text"), //
+ SLIDE_BARCODE_HEIGHT("heightSlideLabels", "text"), //
+ SLIDE_BARCODE_WIDTH("widthSlideLabels", "text"), //
+ ALT_ACCESSION_PREFIX("prePrintAltAccessionPrefix", "text"), //
+ USE_ALT_ACCESSION_PREFIX("prePrintUseAltAccession", "text"), //
+ USE_ALPHANUM_ACCESSION_PREFIX("useAlphanumAccessionPrefix", "text"), //
+ ALPHANUM_ACCESSION_PREFIX("alphanumAccessionPrefix", "text"), //
+ LAB_DIRECTOR_NAME("labDirectorName", "text"), //
+ LAB_DIRECTOR_TITLE("labDirectorTitle", "text"), //
+ INFO_HIGHWAY_USERNAME("infoHighway.username", "text"), //
+ INFO_HIGHWAY_PASSWORD("infoHighway.password", "text"), //
+ INFO_HIGHWAY_ADDRESS("infoHighway.uri", "text"), //
+ INFO_HIGHWAY_ENABLED("infoHighway.enabled", "text"), //
+ PATIENT_RESULTS_BMP_SMS_USERNAME("patientresultsbmpsms.username", "text"), //
+ PATIENT_RESULTS_BMP_SMS_PASSWORD("patientresultsbmpsms.password", "text"), //
+ PATIENT_RESULTS_BMP_SMS_ADDRESS("patientresultsbmpsms.uri", "text"), //
+ PATIENT_RESULTS_BMP_SMS_ENABLED("patientresultsbmpsms.enabled", "text"), //
+ PATIENT_RESULTS_SMPP_SMS_USERNAME("patientresultssmpp.username", "text"), //
+ PATIENT_RESULTS_SMPP_SMS_PASSWORD("patientresultssmpp.password", "text"), //
+ PATIENT_RESULTS_SMPP_SMS_ADDRESS("patientresultssmpp.uri", "text"), //
+ PATIENT_RESULTS_SMPP_SMS_ENABLED("patientresultssmpp.enabled", "text"), //
+ PATIENT_RESULTS_SMTP_USERNAME("patientresultssmtp.username", "text"), //
+ PATIENT_RESULTS_SMTP_PASSWORD("patientresultssmtp.password", "text"), //
+ PATIENT_RESULTS_SMTP_ADDRESS("patientresultssmtp.uri", "text"), //
+ PATIENT_RESULTS_SMTP_ENABLED("patientresultssmtp.enabled", "text"), //
+ CONTACT_TRACING("contactTracingEnabled", "text"), //
+ REQUIRE_LAB_UNIT_AT_LOGIN("requireLabUnitAtLogin", "text"), //
+ ENABLE_CLIENT_REGISTRY("enableClientRegistry", "text"); // if true, then client registry search option is
+ // visible on
+ // the ui
- private String name;
+ private String dbName;
+ private String propertyType; // text, localization
- private Property(String name) {
- this.name = name;
+ private Property(String dbName, String propertyType) {
+ this.dbName = dbName;
+ this.propertyType = propertyType;
}
- public String getName() {
- return name;
+ public String getDBName() {
+ return dbName;
}
- }
- public static ConfigurationProperties getInstance() {
- synchronized (lockObj) {
- if (activeConcreteInstance == null) {
- activeConcreteInstance = new DefaultConfigurationProperties();
+ public static Property fromDBName(String name) {
+ for (Property e : Property.values()) {
+ if (e.getDBName().equals(name))
+ return e;
}
+ return null;
+ }
+
+ public String getPropertyType() {
+ return propertyType;
}
- return activeConcreteInstance;
}
- public String getPropertyValue(Property property) {
- loadIfPropertyValueNeeded(property);
+ public static ConfigurationProperties getInstance() {
+ return SpringContext.getBean(DefaultConfigurationProperties.class);
+ }
- return GenericValidator.isBlankOrNull(propertiesValueMap.get(property)) ? null
- : propertiesValueMap.get(property).trim();
+ public String getPropertyValue(String propertyName) {
+ return GenericValidator.isBlankOrNull(finalProperties.getProperty(propertyName)) ? null
+ : finalProperties.getProperty(propertyName).trim();
+ }
+
+ public String getPropertyValue(Property property) {
+ return GenericValidator.isBlankOrNull(finalProperties.getProperty(property.name())) ? null
+ : finalProperties.getProperty(property.name()).trim();
}
public String getPropertyValueUpperCase(Property property) {
@@ -238,14 +283,14 @@ public String getPropertyValueLowerCase(Property property) {
}
public static void forceReload() {
- activeConcreteInstance = null;
+ SpringContext.getBean(DefaultConfigurationProperties.class).initialize();
SpringContext.getBean(ConfigurationListenerService.class).refreshConfigurations();
}
- /*
- * Allowing for lazy loading.
- */
- protected abstract void loadIfPropertyValueNeeded(Property property);
+ public static void loadDBValuesIntoConfiguration() {
+ SpringContext.getBean(DefaultConfigurationProperties.class).loadChangedValuesFromDatabaseIntoFinalProperties();
+ SpringContext.getBean(ConfigurationListenerService.class).refreshConfigurations();
+ }
public boolean isPropertyValueEqual(Property property, String target) {
@@ -265,15 +310,6 @@ public boolean isCaseInsensitivePropertyValueEqual(Property property, String tar
}
public void setPropertyValue(Property property, String value) {
- propertiesValueMap.put(property, value);
- }
-
- /**
- * For testing only to set a controllable singleton
- *
- * @param activeConcreteInstance
- */
- public static void setActiveConcreteInstance(ConfigurationProperties activeConcreteInstance) {
- ConfigurationProperties.activeConcreteInstance = activeConcreteInstance;
+ finalProperties.setPropertyValue(property.name(), value);
}
}
diff --git a/src/main/java/org/openelisglobal/common/util/ConfigurationSideEffects.java b/src/main/java/org/openelisglobal/common/util/ConfigurationSideEffects.java
index 816309e218..9b2eb487d7 100644
--- a/src/main/java/org/openelisglobal/common/util/ConfigurationSideEffects.java
+++ b/src/main/java/org/openelisglobal/common/util/ConfigurationSideEffects.java
@@ -30,12 +30,12 @@ public class ConfigurationSideEffects {
private SiteInformationService siteInformationService;
public void siteInformationChanged(SiteInformation siteInformation) {
- if (Property.DEFAULT_LANG_LOCALE.getName().equals(siteInformation.getName())) {
+ if (Property.DEFAULT_LANG_LOCALE.getDBName().equals(siteInformation.getName())) {
// this is done in SiteInformationController.java as we need to have the user
// request to change the locale
}
- if (Property.roleRequiredForModifyResults.getName().equals(siteInformation.getName())) {
+ if (Property.roleRequiredForModifyResults.getDBName().equals(siteInformation.getName())) {
Role modifierRole = roleService.getRoleByName("Results modifier");
if (modifierRole != null && modifierRole.getId() != null) {
@@ -45,7 +45,7 @@ public void siteInformationChanged(SiteInformation siteInformation) {
}
}
- if (Property.SiteCode.getName().equals(siteInformation.getName())) {
+ if (Property.SiteCode.getDBName().equals(siteInformation.getName())) {
SiteInformation accessionFormat = siteInformationService.getSiteInformationByName("acessionFormat");
if ("SITEYEARNUM".equals(accessionFormat.getValue())) {
SiteInformation accessionPrefix = siteInformationService
diff --git a/src/main/java/org/openelisglobal/common/util/DateUtil.java b/src/main/java/org/openelisglobal/common/util/DateUtil.java
index 767ba43555..bbfb61a4f8 100644
--- a/src/main/java/org/openelisglobal/common/util/DateUtil.java
+++ b/src/main/java/org/openelisglobal/common/util/DateUtil.java
@@ -71,13 +71,14 @@ public static String formatDateAsText(Date date) {
}
public static java.sql.Date convertStringDateToSqlDate(String date) {
- String stringLocale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String stringLocale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
return convertStringDateToSqlDate(date, stringLocale);
}
public static LocalDate convertStringDateToLocalDate(String date) {
- Locale locale = SystemConfiguration.getInstance().getDefaultLocale();
+ Locale locale = Locale
+ .forLanguageTag(ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE));
return convertStringDateToLocalDate(date, locale);
}
@@ -172,7 +173,8 @@ public static Timestamp convertStringDateToTimestampWithPatternNoLocale(String d
public static Timestamp convertStringDateToTimestampWithPattern(String date, String pattern)
throws LIMSRuntimeException {
- Locale locale = SystemConfiguration.getInstance().getDefaultLocale();
+ Locale locale = Locale
+ .forLanguageTag(ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE));
SimpleDateFormat format = new SimpleDateFormat(pattern, locale);
Timestamp returnTimestamp = null;
@@ -674,8 +676,8 @@ public static String getDateTime12HourFormat() {
}
public static Locale getDateFormatLocale() {
- return SystemConfiguration.getInstance().getLocaleByLocalString(
- ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_DATE_LOCALE));
+ return Locale
+ .forLanguageTag(ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_DATE_LOCALE));
}
public static String getTimeUserPrompt() {
diff --git a/src/main/java/org/openelisglobal/common/util/DefaultConfigurationProperties.java b/src/main/java/org/openelisglobal/common/util/DefaultConfigurationProperties.java
index b447a45785..fa56f725fb 100644
--- a/src/main/java/org/openelisglobal/common/util/DefaultConfigurationProperties.java
+++ b/src/main/java/org/openelisglobal/common/util/DefaultConfigurationProperties.java
@@ -13,12 +13,29 @@
*/
package org.openelisglobal.common.util;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Optional;
+import java.util.Properties;
+import java.util.Set;
+import java.util.regex.Pattern;
+import javax.annotation.PostConstruct;
+import org.apache.commons.lang3.EnumUtils;
import org.openelisglobal.common.action.IActionConstants;
import org.openelisglobal.common.log.LogEvent;
import org.openelisglobal.externalconnections.service.BasicAuthenticationDataService;
@@ -26,346 +43,410 @@
import org.openelisglobal.externalconnections.valueholder.BasicAuthenticationData;
import org.openelisglobal.externalconnections.valueholder.ExternalConnection;
import org.openelisglobal.externalconnections.valueholder.ExternalConnection.ProgrammedConnection;
+import org.openelisglobal.localization.service.LocalizationService;
+import org.openelisglobal.localization.valueholder.Localization;
import org.openelisglobal.siteinformation.service.SiteInformationService;
import org.openelisglobal.siteinformation.valueholder.SiteInformation;
import org.openelisglobal.spring.util.SpringContext;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+@Component
public class DefaultConfigurationProperties extends ConfigurationProperties {
- private static String propertyFile = "/SystemConfiguration.properties";
- private java.util.Properties properties = null;
- protected static Map propertiesFileMap;
- protected static Map dbNamePropertiesMap;
-
- private boolean databaseLoaded = false;
-
- {
- // config from SystemConfiguration.properties
- propertiesFileMap = new HashMap<>();
- propertiesFileMap.put(Property.AmbiguousDateValue, new KeyDefaultPair("date.ambiguous.date.value", "01"));
- propertiesFileMap.put(Property.AmbiguousDateHolder, new KeyDefaultPair("date.ambiguous.date.holder", "X"));
- propertiesFileMap.put(Property.ReferingLabParentOrg,
- new KeyDefaultPair("organization.reference.lab.parent", null));
- propertiesFileMap.put(Property.resultsResendTime, new KeyDefaultPair("results.send.retry.time", "30"));
-
- // propertiesFileMap.put(Property. , new KeyDefaultPair() );
-
- // config from site_information table
- dbNamePropertiesMap = new HashMap<>();
- setDBPropertyMappingAndDefault(Property.SiteCode, Property.SiteCode.getName(), "");
- setDBPropertyMappingAndDefault(Property.TrainingInstallation, Property.TrainingInstallation.getName(), "false");
- setDBPropertyMappingAndDefault(Property.PatientSearchURL, Property.PatientSearchURL.getName(), "");
- setDBPropertyMappingAndDefault(Property.PatientSearchUserName, Property.PatientSearchUserName.getName(), "");
- setDBPropertyMappingAndDefault(Property.PatientSearchPassword, Property.PatientSearchPassword.getName(), "");
- setDBPropertyMappingAndDefault(Property.PatientSearchEnabled, Property.PatientSearchEnabled.getName(), "false");
- setDBPropertyMappingAndDefault(Property.UseExternalPatientInfo, Property.UseExternalPatientInfo.getName(),
- "false");
- setDBPropertyMappingAndDefault(Property.labDirectorName, Property.labDirectorName.getName(), "");
- setDBPropertyMappingAndDefault(Property.languageSwitch, Property.languageSwitch.getName(), "true");
- setDBPropertyMappingAndDefault(Property.resultReportingURL, Property.resultReportingURL.getName(), "");
- setDBPropertyMappingAndDefault(Property.reportResults, Property.reportResults.getName(), "false");
- setDBPropertyMappingAndDefault(Property.malariaSurveillanceReportURL,
- Property.malariaSurveillanceReportURL.getName(), "");
- setDBPropertyMappingAndDefault(Property.malariaSurveillanceReport, Property.malariaSurveillanceReport.getName(),
- "false");
- setDBPropertyMappingAndDefault(Property.malariaCaseReport, Property.malariaCaseReport.getName(), "false");
- setDBPropertyMappingAndDefault(Property.malariaCaseReportURL, Property.malariaCaseReportURL.getName(), "");
- setDBPropertyMappingAndDefault(Property.testUsageReportingURL, Property.testUsageReportingURL.getName(), "");
- setDBPropertyMappingAndDefault(Property.testUsageReporting, Property.testUsageReporting.getName(), "false");
- setDBPropertyMappingAndDefault(Property.roleRequiredForModifyResults,
- Property.roleRequiredForModifyResults.getName(), "false");
- setDBPropertyMappingAndDefault(Property.notesRequiredForModifyResults,
- Property.notesRequiredForModifyResults.getName(), "false");
- setDBPropertyMappingAndDefault(Property.resultTechnicianName, Property.resultTechnicianName.getName(), "false");
- setDBPropertyMappingAndDefault(Property.customCriticalMessage, Property.customCriticalMessage.getName(), "");
- setDBPropertyMappingAndDefault(Property.allowResultRejection, Property.allowResultRejection.getName(), "false");
- setDBPropertyMappingAndDefault(Property.restrictFreeTextRefSiteEntry,
- Property.restrictFreeTextRefSiteEntry.getName(), "false");
- setDBPropertyMappingAndDefault(Property.restrictFreeTextMethodEntry,
- Property.restrictFreeTextMethodEntry.getName(), "false");
- setDBPropertyMappingAndDefault(Property.restrictFreeTextProviderEntry,
- Property.restrictFreeTextProviderEntry.getName(), "false");
- setDBPropertyMappingAndDefault(Property.autoFillTechNameBox, Property.autoFillTechNameBox.getName(), "false");
- setDBPropertyMappingAndDefault(Property.autoFillTechNameUser, Property.autoFillTechNameUser.getName(), "false");
- setDBPropertyMappingAndDefault(Property.failedValidationMarker, Property.failedValidationMarker.getName(),
- "true");
- setDBPropertyMappingAndDefault(Property.SiteName, Property.SiteName.getName(), "");
- setDBPropertyMappingAndDefault(Property.Addressline1label, Property.Addressline1label.getName(), "");
- setDBPropertyMappingAndDefault(Property.Addressline2label, Property.Addressline2label.getName(), "");
- setDBPropertyMappingAndDefault(Property.Addressline3label, Property.Addressline3label.getName(), "");
- setDBPropertyMappingAndDefault(Property.GeographicUnit1Label, Property.GeographicUnit1Label.getName(), "");
- setDBPropertyMappingAndDefault(Property.GeographicUnit2Label, Property.GeographicUnit2Label.getName(), "");
- setDBPropertyMappingAndDefault(Property.PasswordRequirments, Property.PasswordRequirments.getName(), "MINN");
- setDBPropertyMappingAndDefault(Property.FormFieldSet, Property.FormFieldSet.getName(),
- IActionConstants.FORM_FIELD_SET_MAURITIUS);
- setDBPropertyMappingAndDefault(Property.StringContext, Property.StringContext.getName(), "");
- setDBPropertyMappingAndDefault(Property.StatusRules, Property.StatusRules.getName(), "CI");
- setDBPropertyMappingAndDefault(Property.ReflexAction, Property.ReflexAction.getName(), "Haiti");
- setDBPropertyMappingAndDefault(Property.AccessionFormat, Property.AccessionFormat.getName(), "SITEYEARNUM"); // spelled
- // wrong
- // in
- // DB
- setDBPropertyMappingAndDefault(Property.TRACK_PATIENT_PAYMENT, Property.TRACK_PATIENT_PAYMENT.getName(),
- "false");
- setDBPropertyMappingAndDefault(Property.ACCESSION_NUMBER_VALIDATE, Property.ACCESSION_NUMBER_VALIDATE.getName(),
- "false");
- setDBPropertyMappingAndDefault(Property.ALERT_FOR_INVALID_RESULTS, Property.ALERT_FOR_INVALID_RESULTS.getName(),
- "false");
- setDBPropertyMappingAndDefault(Property.DEFAULT_DATE_LOCALE, Property.DEFAULT_DATE_LOCALE.getName(), "fr-FR");
- setDBPropertyMappingAndDefault(Property.DEFAULT_LANG_LOCALE, Property.DEFAULT_LANG_LOCALE.getName(), "fr-FR");
- setDBPropertyMappingAndDefault(Property.configurationName, Property.configurationName.getName(), "not set");
- setDBPropertyMappingAndDefault(Property.CONDENSE_NFS_PANEL, Property.CONDENSE_NFS_PANEL.getName(), "false");
- setDBPropertyMappingAndDefault(Property.PATIENT_DATA_ON_RESULTS_BY_ROLE,
- Property.PATIENT_DATA_ON_RESULTS_BY_ROLE.getName(), "false");
- setDBPropertyMappingAndDefault(Property.USE_PAGE_NUMBERS_ON_REPORTS,
- Property.USE_PAGE_NUMBERS_ON_REPORTS.getName(), "true");
- setDBPropertyMappingAndDefault(Property.QA_SORT_EVENT_LIST, Property.QA_SORT_EVENT_LIST.getName(), "true");
- setDBPropertyMappingAndDefault(Property.ALWAYS_VALIDATE_RESULTS, Property.ALWAYS_VALIDATE_RESULTS.getName(),
- "true");
- setDBPropertyMappingAndDefault(Property.ADDITIONAL_SITE_INFO, Property.ADDITIONAL_SITE_INFO.getName(), "");
- setDBPropertyMappingAndDefault(Property.SUBJECT_ON_WORKPLAN, Property.SUBJECT_ON_WORKPLAN.getName(), "false");
- setDBPropertyMappingAndDefault(Property.NEXT_VISIT_DATE_ON_WORKPLAN,
- Property.NEXT_VISIT_DATE_ON_WORKPLAN.getName(), "false");
- setDBPropertyMappingAndDefault(Property.ACCEPT_EXTERNAL_ORDERS, Property.ACCEPT_EXTERNAL_ORDERS.getName(),
- "false");
- setDBPropertyMappingAndDefault(Property.SIGNATURES_ON_NONCONFORMITY_REPORTS,
- Property.SIGNATURES_ON_NONCONFORMITY_REPORTS.getName(), "false");
- setDBPropertyMappingAndDefault(Property.AUTOFILL_COLLECTION_DATE, Property.AUTOFILL_COLLECTION_DATE.getName(),
- "true");
- setDBPropertyMappingAndDefault(Property.RESULTS_ON_WORKPLAN, Property.RESULTS_ON_WORKPLAN.getName(), "false");
- setDBPropertyMappingAndDefault(Property.NONCONFORMITY_RECEPTION_AS_UNIT,
- Property.NONCONFORMITY_RECEPTION_AS_UNIT.getName(), "true");
- setDBPropertyMappingAndDefault(Property.NONCONFORMITY_SAMPLE_COLLECTION_AS_UNIT,
- Property.NONCONFORMITY_SAMPLE_COLLECTION_AS_UNIT.getName(), "false");
- setDBPropertyMappingAndDefault(Property.ACCESSION_NUMBER_PREFIX, Property.ACCESSION_NUMBER_PREFIX.getName(),
- "");
- setDBPropertyMappingAndDefault(Property.NOTE_EXTERNAL_ONLY_FOR_VALIDATION,
- Property.NOTE_EXTERNAL_ONLY_FOR_VALIDATION.getName(), "false");
- setDBPropertyMappingAndDefault(Property.PHONE_FORMAT, Property.PHONE_FORMAT.getName(), "(ddd) dddd-dddd");
- setDBPropertyMappingAndDefault(Property.VALIDATE_PHONE_FORMAT, Property.VALIDATE_PHONE_FORMAT.getName(),
- "true");
- setDBPropertyMappingAndDefault(Property.ALLOW_DUPLICATE_SUBJECT_NUMBERS,
- Property.ALLOW_DUPLICATE_SUBJECT_NUMBERS.getName(), "true");
- setDBPropertyMappingAndDefault(Property.ALLOW_DUPLICATE_NATIONAL_IDS,
- Property.ALLOW_DUPLICATE_NATIONAL_IDS.getName(), "false");
-
- setDBPropertyMappingAndDefault(Property.VALIDATE_REJECTED_TESTS, Property.VALIDATE_REJECTED_TESTS.getName(),
- "false");
- setDBPropertyMappingAndDefault(Property.TEST_NAME_AUGMENTED, Property.TEST_NAME_AUGMENTED.getName(), "true");
- setDBPropertyMappingAndDefault(Property.USE_BILLING_REFERENCE_NUMBER,
- Property.USE_BILLING_REFERENCE_NUMBER.getName(), "false");
- setDBPropertyMappingAndDefault(Property.BILLING_REFERENCE_NUMBER_LABEL,
- Property.BILLING_REFERENCE_NUMBER_LABEL.getName(), "-1");
- setDBPropertyMappingAndDefault(Property.ORDER_PROGRAM, Property.ORDER_PROGRAM.getName(), "true");
- setDBPropertyMappingAndDefault(Property.BANNER_TEXT, Property.BANNER_TEXT.getName(), "-1");
- setDBPropertyMappingAndDefault(Property.CLOCK_24, Property.CLOCK_24.getName(), "true");
- setDBPropertyMappingAndDefault(Property.PATIENT_NATIONALITY, Property.PATIENT_NATIONALITY.getName(), "false");
- setDBPropertyMappingAndDefault(Property.PATIENT_ID_REQUIRED, Property.PATIENT_ID_REQUIRED.getName(), "true");
- setDBPropertyMappingAndDefault(Property.PATIENT_SUBJECT_NUMBER_REQUIRED,
- Property.PATIENT_SUBJECT_NUMBER_REQUIRED.getName(), "true");
- setDBPropertyMappingAndDefault(Property.PATIENT_NATIONAL_ID_REQUIRED,
- Property.PATIENT_NATIONAL_ID_REQUIRED.getName(), "true");
-
- setDBPropertyMappingAndDefault(Property.QA_SAMPLE_ID_REQUIRED, Property.QA_SAMPLE_ID_REQUIRED.getName(),
- "false");
- setDBPropertyMappingAndDefault(Property.MAX_ORDER_PRINTED, Property.MAX_ORDER_PRINTED.getName(), "10");
- setDBPropertyMappingAndDefault(Property.MAX_SPECIMEN_PRINTED, Property.MAX_SPECIMEN_PRINTED.getName(), "1");
- setDBPropertyMappingAndDefault(Property.MAX_ALIQUOT_PRINTED, Property.MAX_ALIQUOT_PRINTED.getName(), "1");
- setDBPropertyMappingAndDefault(Property.DEFAULT_ORDER_PRINTED, Property.DEFAULT_ORDER_PRINTED.getName(), "2");
- setDBPropertyMappingAndDefault(Property.DEFAULT_SPECIMEN_PRINTED, Property.DEFAULT_SPECIMEN_PRINTED.getName(),
- "1");
- setDBPropertyMappingAndDefault(Property.DEFAULT_ALIQUOT_PRINTED, Property.DEFAULT_ALIQUOT_PRINTED.getName(),
- "1");
- setDBPropertyMappingAndDefault(Property.ORDER_BARCODE_HEIGHT, Property.ORDER_BARCODE_HEIGHT.getName(), "25.4");
- setDBPropertyMappingAndDefault(Property.ORDER_BARCODE_WIDTH, Property.ORDER_BARCODE_WIDTH.getName(), "76.2");
- setDBPropertyMappingAndDefault(Property.SPECIMEN_BARCODE_HEIGHT, Property.SPECIMEN_BARCODE_HEIGHT.getName(),
- "25.4");
- setDBPropertyMappingAndDefault(Property.SPECIMEN_BARCODE_WIDTH, Property.SPECIMEN_BARCODE_WIDTH.getName(),
- "76.2");
- setDBPropertyMappingAndDefault(Property.BLOCK_BARCODE_HEIGHT, Property.BLOCK_BARCODE_HEIGHT.getName(), "25.4");
- setDBPropertyMappingAndDefault(Property.BLOCK_BARCODE_WIDTH, Property.BLOCK_BARCODE_WIDTH.getName(), "76.2");
- setDBPropertyMappingAndDefault(Property.SLIDE_BARCODE_HEIGHT, Property.SLIDE_BARCODE_HEIGHT.getName(), "25.4");
- setDBPropertyMappingAndDefault(Property.SLIDE_BARCODE_WIDTH, Property.SLIDE_BARCODE_WIDTH.getName(), "76.2");
- setDBPropertyMappingAndDefault(Property.SPECIMEN_FIELD_DATE, Property.SPECIMEN_FIELD_DATE.getName(), "true");
- setDBPropertyMappingAndDefault(Property.SPECIMEN_FIELD_COLLECTED_BY,
- Property.SPECIMEN_FIELD_COLLECTED_BY.getName(), "true");
- setDBPropertyMappingAndDefault(Property.SPECIMEN_FIELD_SEX, Property.SPECIMEN_FIELD_SEX.getName(), "true");
- setDBPropertyMappingAndDefault(Property.SPECIMEN_FIELD_TESTS, Property.SPECIMEN_FIELD_TESTS.getName(), "true");
-
- setDBPropertyMappingAndDefault(Property.ALT_ACCESSION_PREFIX, Property.ALT_ACCESSION_PREFIX.getName(), "");
- setDBPropertyMappingAndDefault(Property.USE_ALT_ACCESSION_PREFIX, Property.USE_ALT_ACCESSION_PREFIX.getName(),
- "false");
-
- setDBPropertyMappingAndDefault(Property.LAB_DIRECTOR_NAME, Property.LAB_DIRECTOR_NAME.getName(), "");
- setDBPropertyMappingAndDefault(Property.LAB_DIRECTOR_TITLE, Property.LAB_DIRECTOR_TITLE.getName(), "");
- setDBPropertyMappingAndDefault(Property.CONTACT_TRACING, Property.CONTACT_TRACING.getName(), "false");
- // these are set through external connection now
- // setDBPropertyMappingAndDefault(Property.INFO_HIGHWAY_ADDRESS,
- // Property.INFO_HIGHWAY_ADDRESS.getName(), "");
- // setDBPropertyMappingAndDefault(Property.INFO_HIGHWAY_USERNAME,
- // Property.INFO_HIGHWAY_USERNAME.getName(), "");
- // setDBPropertyMappingAndDefault(Property.INFO_HIGHWAY_PASSWORD,
- // Property.INFO_HIGHWAY_PASSWORD.getName(), "");
- // setDBPropertyMappingAndDefault(Property.INFO_HIGHWAY_ENABLED,
- // Property.INFO_HIGHWAY_ENABLED.getName(), "");
- setDBPropertyMappingAndDefault(Property.ALPHANUM_ACCESSION_PREFIX, Property.ALPHANUM_ACCESSION_PREFIX.getName(),
- "");
- setDBPropertyMappingAndDefault(Property.USE_ALPHANUM_ACCESSION_PREFIX,
- Property.USE_ALPHANUM_ACCESSION_PREFIX.getName(), "false");
- setDBPropertyMappingAndDefault(Property.REQUIRE_LAB_UNIT_AT_LOGIN, Property.REQUIRE_LAB_UNIT_AT_LOGIN.getName(),
- "false");
- setDBPropertyMappingAndDefault(Property.ENABLE_CLIENT_REGISTRY, Property.ENABLE_CLIENT_REGISTRY.getName(),
- "false");
- }
+ @Autowired
+ private SiteInformationService siteInformationService;
+ @Autowired
+ private BasicAuthenticationDataService basicAuthenticationDataService;
+ @Autowired
+ private ExternalConnectionService externalConnectionsService;
+
+ // order of preference from least to most preferred is:
+ // hardcoded value,
+ // defaultPropertyFile,
+ // stored value in database, //should we remove if possible?
+ // finalPropertyFile,
+ // changeValuePropertyFile, (migrated into finalPropertyFile and moved)
+ // runtime updates through admin page (put into finalPropertyFile and db)
+ // version number file
+
+ // finalPropertyFile is written at the end of all changes, and when db changes
+ // occur
+ // the finalPropertyFile contents are also written to db values when originally
+ // loaded
+
+ private String defaultPropertyFile = "/SystemConfiguration.properties";
+ private String changeValuePropertyFile = "/var/lib/openelis-global/properties/SystemConfiguration.properties";
+ private String changedValuePropertyFile = "/var/lib/openelis-global/properties/ChangedSystemConfiguration.properties";
+ private String finalPropertyFile = "/var/lib/openelis-global/properties/TotalSystemConfiguration.properties";
+ private OEProperties hardcodedDefaultProperties;
+ private OEProperties defaultProperties;
+ private OEProperties dbOnLoadProperties;
+ private OEProperties changeProperty;
+
+ @PostConstruct
+ public void initialize() {
+ LogEvent.logDebug(this.getClass().getSimpleName(), "initialize", "initializing configuration");
+ hardcodedDefaultProperties = loadHardcodedProperties();
+ defaultProperties = loadFromPropertyFileResource(defaultPropertyFile);
+ dbOnLoadProperties = loadFromDatabase();
+ finalProperties = loadFromPropertyFile(finalPropertyFile);
+ changeProperty = loadFromPropertyFile(changeValuePropertyFile);
+
+ copyPropertiesPreferDestination(dbOnLoadProperties, finalProperties);
+ copyPropertiesPreferDestination(defaultProperties, finalProperties);
+ copyPropertiesPreferDestination(hardcodedDefaultProperties, finalProperties);
+ copyPropertiesPreferSource(changeProperty, finalProperties);
+ try {
+ moveConfigFile(changeValuePropertyFile, changedValuePropertyFile);
+ } catch (IOException e) {
+ LogEvent.logError(e);
+ }
+ try {
+ saveFinalConfigFileAndOverwriteDbValues();
+ } catch (IOException e) {
+ LogEvent.logError(e);
+ }
+ finalProperties.setPropertyValue(Property.releaseNumber.name(),
+ SpringContext.getBean(Versioning.class).getReleaseNumber());
+ LogEvent.logDebug(this.getClass().getSimpleName(), "initialize", "finished initializing configuration");
+ SpringContext.getBean(ConfigurationListenerService.class).refreshConfigurations();
- private void setDBPropertyMappingAndDefault(Property property, String dbName, String defaultValue) {
- dbNamePropertiesMap.put(dbName, property);
- propertiesValueMap.put(property, defaultValue);
}
- protected DefaultConfigurationProperties() {
- loadFromPropertiesFile();
- loadSpecial();
+ private void copyPropertiesPreferSource(OEProperties sourceProperties, OEProperties destinationProperties) {
+ for (String propertyName : sourceProperties.stringPropertyNames()) {
+ if (EnumUtils.isValidEnum(Property.class, propertyName)) {
+ destinationProperties.setPropertyHolder(Property.valueOf(propertyName),
+ sourceProperties.getPropertyHolder(Property.valueOf(propertyName)));
+ } else {
+ destinationProperties.setPropertyValue(propertyName, sourceProperties.getProperty(propertyName));
+ }
+ }
}
- @Override
- protected void loadIfPropertyValueNeeded(Property property) {
- if (!databaseLoaded && dbNamePropertiesMap.containsValue(property)) {
- loadFromDatabase();
+ private void copyPropertiesPreferDestination(OEProperties sourceProperties, OEProperties destinationProperties) {
+ for (String propertyName : sourceProperties.stringPropertyNames()) {
+ if (!destinationProperties.containsKey(propertyName)) {
+ if (EnumUtils.isValidEnum(Property.class, propertyName)) {
+ destinationProperties.setPropertyHolder(Property.valueOf(propertyName),
+ sourceProperties.getPropertyHolder(Property.valueOf(propertyName)));
+ } else {
+ destinationProperties.setPropertyValue(propertyName, sourceProperties.getProperty(propertyName));
+ }
+ }
}
}
- protected void loadExternalConnectionsFromDatabase() {
- ExternalConnectionService externalConnectionsService = SpringContext.getBean(ExternalConnectionService.class);
- BasicAuthenticationDataService basicAuthenticationDataService = SpringContext
- .getBean(BasicAuthenticationDataService.class);
-
- Optional infoHighwayConnection = externalConnectionsService.getMatch("programmedConnection",
- ProgrammedConnection.INFO_HIGHWAY.name());
- propertiesValueMap.put(Property.INFO_HIGHWAY_ENABLED, Boolean.FALSE.toString());
- if (infoHighwayConnection.isPresent()) {
- Optional basicAuthData = basicAuthenticationDataService
- .getByExternalConnection(infoHighwayConnection.get().getId());
- // basic auth is required for info highway
- if (basicAuthData.isPresent()) {
- propertiesValueMap.put(Property.INFO_HIGHWAY_ADDRESS, infoHighwayConnection.get().getUri().toString());
- propertiesValueMap.put(Property.INFO_HIGHWAY_USERNAME, basicAuthData.get().getUsername());
- propertiesValueMap.put(Property.INFO_HIGHWAY_PASSWORD, basicAuthData.get().getPassword());
- if (infoHighwayConnection.get().getActive() != null) {
- propertiesValueMap.put(Property.INFO_HIGHWAY_ENABLED,
- infoHighwayConnection.get().getActive().toString());
+ private void saveFinalConfigFileAndOverwriteDbValues() throws FileNotFoundException, IOException {
+ LogEvent.logDebug(this.getClass().getSimpleName(), "saveFinalConfigFileAndOverwriteDbValues",
+ "saveFinalConfigFileAndOverwriteDbValues");
+ saveFinalConfigFile();
+ for (String propertyName : finalProperties.stringPropertyNames()) {
+ if (EnumUtils.isValidEnum(Property.class, propertyName)) {
+ Property property = Property.valueOf(propertyName);
+ PropertyHolder propertyHolder = finalProperties.getPropertyHolder(property);
+ SiteInformation siteInformation = siteInformationService.getSiteInformationByName(property.getDBName());
+ if (property.getPropertyType().equals("localization")) {
+ Localization localization = SpringContext.getBean(LocalizationService.class)
+ .get(siteInformation.getValue());
+ for (Locale locale : propertyHolder.getLocales()) {
+ localization.setLocalizedValue(locale, propertyHolder.getValue(locale));
+ }
+ SpringContext.getBean(LocalizationService.class).save(localization);
+ } else if (property.getPropertyType().equals("connection")) {
+ // TODO save over external connection variables
+ } else if (property.getPropertyType().equals("text")) {
+ if (siteInformation == null) {
+ // not a db value, nothing to save
+ } else {
+ siteInformation.setValue(propertyHolder.getValue());
+ siteInformationService.save(siteInformation);
+ }
}
}
+
}
- Optional smtpConnection = externalConnectionsService.getMatch("programmedConnection",
- ProgrammedConnection.SMTP_SERVER.name());
- propertiesValueMap.put(Property.PATIENT_RESULTS_SMTP_ENABLED, Boolean.FALSE.toString());
- if (smtpConnection.isPresent()) {
- Optional basicAuthData = basicAuthenticationDataService
- .getByExternalConnection(smtpConnection.get().getId());
- propertiesValueMap.put(Property.PATIENT_RESULTS_SMTP_ADDRESS, smtpConnection.get().getUri().toString());
- // basic auth only required if smtp server haas username password
- if (basicAuthData.isPresent()) {
- propertiesValueMap.put(Property.PATIENT_RESULTS_SMTP_USERNAME, basicAuthData.get().getUsername());
- propertiesValueMap.put(Property.PATIENT_RESULTS_SMTP_PASSWORD, basicAuthData.get().getPassword());
- }
- if (smtpConnection.get().getActive() != null) {
- propertiesValueMap.put(Property.PATIENT_RESULTS_SMTP_ENABLED,
- smtpConnection.get().getActive().toString());
- }
+
+ }
+
+ public String getConfigAsJSONString() throws JsonProcessingException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ return objectMapper.writeValueAsString(finalProperties);
+ }
+
+ private void saveFinalConfigFile() throws FileNotFoundException, IOException {
+ LogEvent.logDebug(this.getClass().getSimpleName(), "saveFinalConfigFile", "saving configuration file");
+ try (final FileOutputStream outputstream = new FileOutputStream(finalPropertyFile);) {
+ finalProperties.getPropertiesForWriting().store(outputstream, "File Updated");
+ outputstream.close();
}
+ }
- Optional bmpSmsConnection = externalConnectionsService.getMatch("programmedConnection",
- ProgrammedConnection.BMP_SMS_SERVER.name());
- propertiesValueMap.put(Property.PATIENT_RESULTS_BMP_SMS_ENABLED, Boolean.FALSE.toString());
- if (bmpSmsConnection.isPresent()) {
- Optional basicAuthData = basicAuthenticationDataService
- .getByExternalConnection(bmpSmsConnection.get().getId());
- propertiesValueMap.put(Property.PATIENT_RESULTS_BMP_SMS_ADDRESS,
- bmpSmsConnection.get().getUri().toString());
- // basic auth only required if bmp sms server has username password
- if (basicAuthData.isPresent()) {
- propertiesValueMap.put(Property.PATIENT_RESULTS_BMP_SMS_USERNAME, basicAuthData.get().getUsername());
- propertiesValueMap.put(Property.PATIENT_RESULTS_BMP_SMS_PASSWORD, basicAuthData.get().getPassword());
- }
- if (bmpSmsConnection.get().getActive() != null) {
- propertiesValueMap.put(Property.PATIENT_RESULTS_BMP_SMS_ENABLED,
- bmpSmsConnection.get().getActive().toString());
- }
+ private void moveConfigFile(String source, String destination) throws IOException {
+ Path sourcePath = Paths.get(source);
+ if (Files.isRegularFile(sourcePath)) {
+ Files.move(Paths.get(source), Paths.get(destination), StandardCopyOption.REPLACE_EXISTING);
}
+ }
- Optional smppSmsConnection = externalConnectionsService.getMatch("programmedConnection",
- ProgrammedConnection.SMPP_SERVER.name());
- propertiesValueMap.put(Property.PATIENT_RESULTS_SMPP_SMS_ENABLED, Boolean.FALSE.toString());
- if (smppSmsConnection.isPresent()) {
+ private OEProperties loadHardcodedProperties() {
+ OEProperties properties = new OEProperties();
+ properties.setPropertyValue(Property.AmbiguousDateValue, "01");
+ properties.setPropertyValue(Property.AmbiguousDateHolder, "X");
+ properties.setPropertyValue(Property.ReferingLabParentOrg, "");
+ properties.setPropertyValue(Property.resultsResendTime, "30");
+
+ properties.setPropertyValue(Property.SiteCode, "");
+ properties.setPropertyValue(Property.TrainingInstallation, "false");
+ properties.setPropertyValue(Property.PatientSearchURL, "");
+ properties.setPropertyValue(Property.PatientSearchUserName, "");
+ properties.setPropertyValue(Property.PatientSearchPassword, "");
+ properties.setPropertyValue(Property.PatientSearchEnabled, "false");
+ properties.setPropertyValue(Property.UseExternalPatientInfo, "false");
+ properties.setPropertyValue(Property.labDirectorName, "");
+ properties.setPropertyValue(Property.languageSwitch, "true");
+ properties.setPropertyValue(Property.resultReportingURL, "");
+ properties.setPropertyValue(Property.reportResults, "false");
+ properties.setPropertyValue(Property.malariaSurveillanceReportURL, "");
+ properties.setPropertyValue(Property.malariaSurveillanceReport, "false");
+ properties.setPropertyValue(Property.malariaCaseReport, "false");
+ properties.setPropertyValue(Property.malariaCaseReportURL, "");
+ properties.setPropertyValue(Property.testUsageReportingURL, "");
+ properties.setPropertyValue(Property.testUsageReporting, "false");
+ properties.setPropertyValue(Property.roleRequiredForModifyResults, "false");
+ properties.setPropertyValue(Property.notesRequiredForModifyResults, "false");
+ properties.setPropertyValue(Property.resultTechnicianName, "false");
+ properties.setPropertyValue(Property.customCriticalMessage, "");
+ properties.setPropertyValue(Property.allowResultRejection, "false");
+ properties.setPropertyValue(Property.restrictFreeTextRefSiteEntry, "false");
+ properties.setPropertyValue(Property.restrictFreeTextMethodEntry, "false");
+ properties.setPropertyValue(Property.restrictFreeTextProviderEntry, "false");
+ properties.setPropertyValue(Property.autoFillTechNameBox, "false");
+ properties.setPropertyValue(Property.autoFillTechNameUser, "false");
+ properties.setPropertyValue(Property.failedValidationMarker, "true");
+ properties.setPropertyValue(Property.SiteName, "");
+ properties.setPropertyValue(Property.Addressline1label, "");
+ properties.setPropertyValue(Property.Addressline2label, "");
+ properties.setPropertyValue(Property.Addressline3label, "");
+ properties.setPropertyValue(Property.GeographicUnit1Label, "");
+ properties.setPropertyValue(Property.GeographicUnit2Label, "");
+ properties.setPropertyValue(Property.PasswordRequirments, "MINN");
+ properties.setPropertyValue(Property.FormFieldSet, IActionConstants.FORM_FIELD_SET_MAURITIUS);
+ properties.setPropertyValue(Property.StringContext, "");
+ properties.setPropertyValue(Property.StatusRules, "CI");
+ properties.setPropertyValue(Property.ReflexAction, "Haiti");
+ properties.setPropertyValue(Property.AccessionFormat, "SITEYEARNUM");
+ properties.setPropertyValue(Property.TRACK_PATIENT_PAYMENT, "false");
+ properties.setPropertyValue(Property.ACCESSION_NUMBER_VALIDATE, "false");
+ properties.setPropertyValue(Property.ALERT_FOR_INVALID_RESULTS, "false");
+ properties.setPropertyValue(Property.DEFAULT_DATE_LOCALE, "fr-FR");
+ properties.setPropertyValue(Property.DEFAULT_LANG_LOCALE, "fr-FR");
+ properties.setPropertyValue(Property.configurationName, "not set");
+ properties.setPropertyValue(Property.CONDENSE_NFS_PANEL, "false");
+ properties.setPropertyValue(Property.PATIENT_DATA_ON_RESULTS_BY_ROLE, "false");
+ properties.setPropertyValue(Property.USE_PAGE_NUMBERS_ON_REPORTS, "true");
+ properties.setPropertyValue(Property.QA_SORT_EVENT_LIST, "true");
+ properties.setPropertyValue(Property.ALWAYS_VALIDATE_RESULTS, "true");
+ properties.setPropertyValue(Property.ADDITIONAL_SITE_INFO, "");
+ properties.setPropertyValue(Property.SUBJECT_ON_WORKPLAN, "false");
+ properties.setPropertyValue(Property.NEXT_VISIT_DATE_ON_WORKPLAN, "false");
+ properties.setPropertyValue(Property.ACCEPT_EXTERNAL_ORDERS, "false");
+ properties.setPropertyValue(Property.SIGNATURES_ON_NONCONFORMITY_REPORTS, "false");
+ properties.setPropertyValue(Property.AUTOFILL_COLLECTION_DATE, "true");
+ properties.setPropertyValue(Property.RESULTS_ON_WORKPLAN, "false");
+ properties.setPropertyValue(Property.NONCONFORMITY_RECEPTION_AS_UNIT, "true");
+ properties.setPropertyValue(Property.NONCONFORMITY_SAMPLE_COLLECTION_AS_UNIT, "false");
+ properties.setPropertyValue(Property.ACCESSION_NUMBER_PREFIX, "");
+ properties.setPropertyValue(Property.NOTE_EXTERNAL_ONLY_FOR_VALIDATION, "false");
+ properties.setPropertyValue(Property.PHONE_FORMAT, "(ddd) dddd-dddd");
+ properties.setPropertyValue(Property.VALIDATE_PHONE_FORMAT, "true");
+ properties.setPropertyValue(Property.ALLOW_DUPLICATE_SUBJECT_NUMBERS, "true");
+ properties.setPropertyValue(Property.ALLOW_DUPLICATE_NATIONAL_IDS, "false");
+
+ properties.setPropertyValue(Property.VALIDATE_REJECTED_TESTS, "false");
+ properties.setPropertyValue(Property.TEST_NAME_AUGMENTED, "true");
+ properties.setPropertyValue(Property.USE_BILLING_REFERENCE_NUMBER, "false");
+ properties.setPropertyHolder(Property.BILLING_REFERENCE_NUMBER_LABEL, new PropertyHolder("-1", true));
+ properties.setPropertyValue(Property.ORDER_PROGRAM, "true");
+ properties.setPropertyHolder(Property.BANNER_TEXT, new PropertyHolder("-1", true));
+ properties.setPropertyValue(Property.CLOCK_24, "true");
+ properties.setPropertyValue(Property.PATIENT_NATIONALITY, "false");
+ properties.setPropertyValue(Property.PATIENT_ID_REQUIRED, "true");
+ properties.setPropertyValue(Property.PATIENT_SUBJECT_NUMBER_REQUIRED, "true");
+ properties.setPropertyValue(Property.PATIENT_NATIONAL_ID_REQUIRED, "true");
+
+ properties.setPropertyValue(Property.QA_SAMPLE_ID_REQUIRED, "false");
+ properties.setPropertyValue(Property.MAX_ORDER_PRINTED, "10");
+ properties.setPropertyValue(Property.MAX_SPECIMEN_PRINTED, "1");
+ properties.setPropertyValue(Property.MAX_ALIQUOT_PRINTED, "1");
+ properties.setPropertyValue(Property.DEFAULT_ORDER_PRINTED, "2");
+ properties.setPropertyValue(Property.DEFAULT_SPECIMEN_PRINTED, "1");
+ properties.setPropertyValue(Property.DEFAULT_ALIQUOT_PRINTED, "1");
+ properties.setPropertyValue(Property.ORDER_BARCODE_HEIGHT, "25.4");
+ properties.setPropertyValue(Property.ORDER_BARCODE_WIDTH, "76.2");
+ properties.setPropertyValue(Property.SPECIMEN_BARCODE_HEIGHT, "25.4");
+ properties.setPropertyValue(Property.SPECIMEN_BARCODE_WIDTH, "76.2");
+ properties.setPropertyValue(Property.BLOCK_BARCODE_HEIGHT, "25.4");
+ properties.setPropertyValue(Property.BLOCK_BARCODE_WIDTH, "76.2");
+ properties.setPropertyValue(Property.SLIDE_BARCODE_HEIGHT, "25.4");
+ properties.setPropertyValue(Property.SLIDE_BARCODE_WIDTH, "76.2");
+ properties.setPropertyValue(Property.SPECIMEN_FIELD_DATE, "true");
+ properties.setPropertyValue(Property.SPECIMEN_FIELD_COLLECTED_BY, "true");
+ properties.setPropertyValue(Property.SPECIMEN_FIELD_SEX, "true");
+ properties.setPropertyValue(Property.SPECIMEN_FIELD_TESTS, "true");
+
+ properties.setPropertyValue(Property.ALT_ACCESSION_PREFIX, "");
+ properties.setPropertyValue(Property.USE_ALT_ACCESSION_PREFIX, "false");
+
+ properties.setPropertyValue(Property.LAB_DIRECTOR_NAME, "");
+ properties.setPropertyValue(Property.LAB_DIRECTOR_TITLE, "");
+ properties.setPropertyValue(Property.CONTACT_TRACING, "false");
+ properties.setPropertyValue(Property.ALPHANUM_ACCESSION_PREFIX, "");
+ properties.setPropertyValue(Property.USE_ALPHANUM_ACCESSION_PREFIX, "false");
+ properties.setPropertyValue(Property.REQUIRE_LAB_UNIT_AT_LOGIN, "false");
+ properties.setPropertyValue(Property.ENABLE_CLIENT_REGISTRY, "false");
+ return properties;
+ }
+
+ // external connections are not stored in the config file, and solely exist in
+ // the database TODO should we make
+ private void loadExternalConnection(Properties properties, ProgrammedConnection connection, Property enabled,
+ Property address, Property username, Property password) {
+ Optional externalConnection = externalConnectionsService.getMatch("programmedConnection",
+ connection.name());
+ properties.setProperty(enabled.name(), Boolean.FALSE.toString());
+ if (externalConnection.isPresent()) {
Optional basicAuthData = basicAuthenticationDataService
- .getByExternalConnection(smppSmsConnection.get().getId());
- propertiesValueMap.put(Property.PATIENT_RESULTS_SMPP_SMS_ADDRESS,
- smppSmsConnection.get().getUri().toString());
- // basic auth only required if smpp server has username password
+ .getByExternalConnection(externalConnection.get().getId());
+ // basic auth is required for info highway
if (basicAuthData.isPresent()) {
- propertiesValueMap.put(Property.PATIENT_RESULTS_SMPP_SMS_USERNAME, basicAuthData.get().getUsername());
- propertiesValueMap.put(Property.PATIENT_RESULTS_SMPP_SMS_PASSWORD, basicAuthData.get().getPassword());
- }
- if (smppSmsConnection.get().getActive() != null) {
- propertiesValueMap.put(Property.PATIENT_RESULTS_SMPP_SMS_ENABLED,
- smppSmsConnection.get().getActive().toString());
+ properties.setProperty(address.name(), externalConnection.get().getUri().toString());
+ properties.setProperty(username.name(), basicAuthData.get().getUsername());
+ properties.setProperty(password.name(), basicAuthData.get().getPassword());
+ if (externalConnection.get().getActive() != null) {
+ properties.setProperty(enabled.name(), externalConnection.get().getActive().toString());
+ }
}
}
+ }
- // Optional clinicConnection =
- // externalConnectionsService.getMatch("programmedConnection",
- // ProgrammedConnection.CLINIC_SEARCH.name());
- // if (clinicConnection.isPresent()) {
- // Optional basicAuthData =
- // basicAuthenticationDataService
- // .getByExternalConnection(clinicConnection.get().getId());
- // if (basicAuthData.isPresent()) {
- // propertiesValueMap.put(Property.PatientSearchURL,
- // clinicConnection.get().getUri().toString());
- // propertiesValueMap.put(Property.PatientSearchUserName,
- // basicAuthData.get().getUsername());
- // propertiesValueMap.put(Property.PatientSearchPassword,
- // basicAuthData.get().getPassword());
- // if (clinicConnection.get().getActive() != null) {
- // propertiesValueMap.put(Property.PatientSearchEnabled,
- // clinicConnection.get().getActive().toString());
- // } else {
- // propertiesValueMap.put(Property.PatientSearchEnabled,
- // Boolean.FALSE.toString());
- // }
- // }
- // }
-
+ private void loadExternalConnectionsFromDatabase(Properties properties) {
+ loadExternalConnection(properties, ProgrammedConnection.INFO_HIGHWAY, Property.INFO_HIGHWAY_ENABLED,
+ Property.INFO_HIGHWAY_ADDRESS, Property.INFO_HIGHWAY_USERNAME, Property.INFO_HIGHWAY_PASSWORD);
+ loadExternalConnection(properties, ProgrammedConnection.SMTP_SERVER, Property.PATIENT_RESULTS_SMTP_ENABLED,
+ Property.PATIENT_RESULTS_SMTP_ADDRESS, Property.PATIENT_RESULTS_SMTP_USERNAME,
+ Property.PATIENT_RESULTS_SMTP_PASSWORD);
+ loadExternalConnection(properties, ProgrammedConnection.BMP_SMS_SERVER,
+ Property.PATIENT_RESULTS_BMP_SMS_ENABLED, Property.PATIENT_RESULTS_BMP_SMS_ADDRESS,
+ Property.PATIENT_RESULTS_BMP_SMS_USERNAME, Property.PATIENT_RESULTS_BMP_SMS_PASSWORD);
+ loadExternalConnection(properties, ProgrammedConnection.SMPP_SERVER, Property.PATIENT_RESULTS_SMPP_SMS_ENABLED,
+ Property.PATIENT_RESULTS_SMPP_SMS_ADDRESS, Property.PATIENT_RESULTS_SMPP_SMS_USERNAME,
+ Property.PATIENT_RESULTS_SMPP_SMS_PASSWORD);
}
- protected void loadFromDatabase() {
- SiteInformationService siteInformationService = SpringContext.getBean(SiteInformationService.class);
+ // two properties are used as the database logic to properties supposrts more
+ // than basic string types.
+ // one property file is used by openelis (will contain things like id values to
+ // localization table)
+ // one property file is used to allow configuration throuh the file and be
+ // easily understood
+ protected OEProperties loadFromDatabase() {
+ OEProperties properties = new OEProperties();
List siteInformationList = siteInformationService.getAllSiteInformation();
for (SiteInformation siteInformation : siteInformationList) {
- Property property = dbNamePropertiesMap.get(siteInformation.getName());
+ Property property = Property.fromDBName(siteInformation.getName());
if (property != null) {
- propertiesValueMap.put(property, siteInformation.getValue());
+ properties.setFullValue(property.name(), siteInformation);
+ } else {
+ properties.setFullValue(siteInformation.getName(), siteInformation);
}
+
+ }
+ Properties externalConnectionsProperties = new Properties();
+ loadExternalConnectionsFromDatabase(externalConnectionsProperties);
+ for (String propertyName : externalConnectionsProperties.stringPropertyNames()) {
+ properties.setPropertyValue(propertyName, externalConnectionsProperties.getProperty(propertyName));
}
- loadExternalConnectionsFromDatabase();
+ return properties;
+ }
- databaseLoaded = true;
+ protected void loadChangedValuesFromDatabaseIntoFinalProperties() {
+ OEProperties changedProperties = loadChangedValuesFromDatabase();
+ copyPropertiesPreferSource(changedProperties, finalProperties);
+ try {
+ saveFinalConfigFile();
+ } catch (IOException e) {
+ LogEvent.logError(e);
+ }
}
- private void loadFromPropertiesFile() {
- InputStream propertyStream = null;
+ protected OEProperties loadChangedValuesFromDatabase() {
+ OEProperties changedProperties = new OEProperties();
+ OEProperties properties = loadFromDatabase();
+ if (finalProperties != null) {
+ for (String propertyName : properties.stringPropertyNames()) {
+ if (!finalProperties.containsKey(propertyName)) {
+ LogEvent.logDebug(this.getClass().getSimpleName(), "loadChangedValuesFromDatabase",
+ propertyName + " is a new property in the database");
+ changedProperties.setPropertyHolder(propertyName, properties.getPropertyHolder(propertyName));
+ } else if (!finalProperties.getPropertyHolder(propertyName)
+ .equals(properties.getPropertyHolder(propertyName))) {
+ LogEvent.logDebug(this.getClass().getSimpleName(), "loadChangedValuesFromDatabase",
+ propertyName + " has changed in the database");
+ changedProperties.setPropertyHolder(propertyName, properties.getPropertyHolder(propertyName));
+ } else {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "loadChangedValuesFromDatabase",
+ propertyName + " has not changed in the database");
+ }
+ }
+ return changedProperties;
+ }
+ return properties;
+ }
+
+ private OEProperties loadFromStream(InputStream propertyStream) throws IOException {
+ OEProperties properties = new OEProperties();
+ Properties loadedProperties = new Properties();
+
+ loadedProperties.load(propertyStream);
+ for (String propertyName : loadedProperties.stringPropertyNames()) {
+ properties.setPropertyFromPropertiesFile(propertyName, loadedProperties.getProperty(propertyName));
+ }
+ return properties;
+ }
+ private OEProperties loadFromPropertyFileResource(String propertyFile) {
+ InputStream propertyStream = null;
try {
propertyStream = this.getClass().getResourceAsStream(propertyFile);
-
// Now load a java.util.Properties object with the properties
- properties = new java.util.Properties();
+ return loadFromStream(propertyStream);
+ } catch (IOException e) {
+ LogEvent.logError(e);
+ } finally {
+ if (null != propertyStream) {
+ try {
+ propertyStream.close();
+ } catch (IOException e) {
+ LogEvent.logError(e);
+ }
+ }
+ }
+ return new OEProperties();
- properties.load(propertyStream);
+ }
+ private OEProperties loadFromPropertyFile(String propertyFile) {
+ InputStream propertyStream = null;
+ try {
+ Path sourcePath = Paths.get(propertyFile);
+ if (Files.isRegularFile(sourcePath)) {
+ propertyStream = Files.newInputStream(Paths.get(propertyFile));
+ return loadFromStream(propertyStream);
+ }
} catch (IOException e) {
LogEvent.logError(e);
} finally {
@@ -377,25 +458,254 @@ private void loadFromPropertiesFile() {
}
}
}
+ return new OEProperties();
- for (Property property : propertiesFileMap.keySet()) {
- KeyDefaultPair pair = propertiesFileMap.get(property);
- String value = properties.getProperty(pair.key, pair.defaultValue);
- propertiesValueMap.put(property, value);
- }
}
- private void loadSpecial() {
- propertiesValueMap.put(Property.releaseNumber, SpringContext.getBean(Versioning.class).getReleaseNumber());
+ public static class PropertyHolder {
+
+ private String propertyValue;
+
+ @JsonIgnore
+ private String localizationId;
+
+ private Map localizationValues;
+
+ public PropertyHolder(String simplePropertyValue) {
+ this.propertyValue = simplePropertyValue;
+ }
+
+ public PropertyHolder(String propertyValue, boolean localization) {
+ if (localization) {
+ this.localizationId = propertyValue;
+ localizationValues = new HashMap<>();
+ }
+ }
+
+ public Set getLocales() {
+ return localizationValues.keySet();
+ }
+
+ public String getValue() {
+ if (null == localizationId) {
+ return propertyValue;
+ }
+ return localizationId;
+ }
+
+ public void setLocalizationValue(Locale locale, String value) {
+ localizationValues.put(locale, value);
+ }
+
+ public String getValue(Locale locale) {
+ return localizationValues.get(locale);
+ }
+
+ private boolean areEqual(Map first, Map second) {
+ if (first == second) {
+ return true;
+ }
+ if (first.size() != second.size()) {
+ return false;
+ }
+
+ return first.entrySet().stream().allMatch(e -> e.getValue().equals(second.get(e.getKey())));
+ }
+
+ public boolean equals(PropertyHolder that) {
+ if (this == that) {
+ return true;
+ }
+ if (that == null) {
+ return false;
+ }
+ return Objects.equals(this.propertyValue, that.propertyValue)
+ && Objects.equals(this.localizationId, that.localizationId)
+ && areEqual(this.localizationValues, that.localizationValues);
+
+ }
}
- protected class KeyDefaultPair {
- public final String key;
- public final String defaultValue;
+ public class OEProperties {
+
+ public static final String SEPERATOR = ".";
+ public static final String LOCALIZATION_PREFIX = "localization";
+ public static final String CONNECTION_PREFIX = "connection";
+
+ Map allProperties;
+
+ OEProperties() {
+ allProperties = new HashMap<>();
+ }
+
+ public void setPropertyHolder(String propertyName, PropertyHolder propertyHolder) {
+ allProperties.put(propertyName, propertyHolder);
+ }
+
+ public PropertyHolder getPropertyHolder(String propertyName) {
+ return allProperties.get(propertyName);
+ }
+
+ public void setPropertyHolder(Property property, PropertyHolder propertyHolder) {
+ setPropertyHolder(property.name(), propertyHolder);
+ }
- public KeyDefaultPair(String key, String defaultValue) {
- this.key = key;
- this.defaultValue = defaultValue;
+ public PropertyHolder getPropertyHolder(Property property) {
+ return getPropertyHolder(property.name());
}
+
+ public void setPropertyValue(Property property, String propertyValue) {
+ setPropertyHolder(property, new PropertyHolder(propertyValue));
+ }
+
+ public void setPropertyValue(String propertyName, String propertyValue) {
+ if (EnumUtils.isValidEnum(Property.class, propertyName)) {
+ setPropertyValue(Property.valueOf(propertyName), propertyValue);
+ } else if (Property.fromDBName(propertyName) != null) {
+ setPropertyValue(Property.fromDBName(propertyName), propertyValue);
+ } else {
+ setPropertyHolder(propertyName, new PropertyHolder(propertyValue));
+ }
+ }
+
+ // full value is the literal value, and the id of the object (ex localization)
+ public void setFullValue(Property property, Locale locale, String value) {
+ SiteInformation siteInformation = siteInformationService.getSiteInformationByName(property.getDBName());
+ if (!"localization".equals(siteInformation.getTag())) {
+ LogEvent.logWarn(this.getClass().getSimpleName(), "setProperty",
+ "siteInformation corresponding to property '" + property.getDBName()
+ + "' is not of type localization");
+ }
+
+ PropertyHolder propertyHolder = getPropertyHolder(property);
+ if (propertyHolder == null) {
+ propertyHolder = new PropertyHolder(siteInformation.getValue(), true);
+ }
+ propertyHolder.setLocalizationValue(locale, value);
+ setPropertyHolder(property, propertyHolder);
+ }
+
+ public void setFullValue(String propertyName, SiteInformation siteInformation) {
+ String[] namePortions = propertyName.split(Pattern.quote(SEPERATOR));
+ if (!EnumUtils.isValidEnum(Property.class, namePortions[namePortions.length - 1])) {
+ LogEvent.logInfo(this.getClass().getSimpleName(), "setProperty",
+ "no enum property could be found matching " + namePortions[namePortions.length - 1]);
+ setPropertyHolder(propertyName, new PropertyHolder(siteInformation.getValue()));
+ } else {
+ switch (siteInformation.getValueType()) {
+ case "logoUpload":
+ case "complex":
+ LogEvent.logInfo(this.getClass().getSimpleName(), "loadFromDatabase",
+ "can't load complex value type from database into property '" + siteInformation.getName()
+ + "'");
+ break;
+ case "text":
+ if ("localization".equals(siteInformation.getTag())) {
+ Localization localization = SpringContext.getBean(LocalizationService.class)
+ .get(siteInformation.getValue());
+ PropertyHolder propertyHolder = allProperties.getOrDefault(
+ namePortions[namePortions.length - 1], new PropertyHolder(localization.getId(), true));
+ if (LOCALIZATION_PREFIX.equals(namePortions[0])) {
+ propertyHolder.setLocalizationValue(Locale.forLanguageTag(namePortions[1]),
+ localization.getLocalizedValue(Locale.forLanguageTag(namePortions[1])));
+ } else {
+ for (Entry localizationEntry : localization.getLocaleValues().entrySet()) {
+ propertyHolder.setLocalizationValue(localizationEntry.getKey(),
+ localizationEntry.getValue());
+ }
+ }
+ setPropertyHolder(Property.valueOf(namePortions[namePortions.length - 1]), propertyHolder);
+ } else {
+ setPropertyHolder(Property.valueOf(propertyName),
+ new PropertyHolder(siteInformation.getValue()));
+ }
+ break;
+ case "freeText":
+ case "dictionary":
+ case "boolean":
+ default:
+ setPropertyHolder(Property.valueOf(propertyName), new PropertyHolder(siteInformation.getValue()));
+ }
+ }
+
+ }
+
+ // loaded property may have info about data type and locale that need to be
+ // parsed out from the property name
+ public void setPropertyFromPropertiesFile(String propertyName, String propertyValue) {
+ String[] namePortions = propertyName.split(Pattern.quote(SEPERATOR));
+ if (!EnumUtils.isValidEnum(Property.class, namePortions[namePortions.length - 1])) {
+ LogEvent.logInfo(this.getClass().getSimpleName(), "setProperty",
+ "no enum property could be found matching " + namePortions[namePortions.length - 1]);
+ setPropertyHolder(propertyName, new PropertyHolder(propertyValue));
+ } else {
+ Property property = Property.valueOf(namePortions[namePortions.length - 1]);
+ if (LOCALIZATION_PREFIX.equals(namePortions[0])) {
+ setFullValue(property, Locale.forLanguageTag(namePortions[1]), propertyValue);
+ } else {
+ setPropertyValue(property, propertyValue);
+ }
+ }
+ }
+
+ public Properties getPropertiesForWriting() {
+ Properties writeableProperties = new Properties();
+ for (Entry propertySet : allProperties.entrySet()) {
+ if (propertySet.getKey() == null) {
+ LogEvent.logWarn(this.getClass().getSimpleName(), "getPropertiesForWriting",
+ "detected null property name");
+ } else {
+ addWriteProperty(writeableProperties, propertySet.getKey(), propertySet.getValue());
+ }
+ }
+ return writeableProperties;
+ }
+
+ // also updates the values in the database
+ private void addWriteProperty(Properties writeableProperties, String propertyName,
+ PropertyHolder propertyHolder) {
+ if (EnumUtils.isValidEnum(Property.class, propertyName)) {
+ Property property = Property.valueOf(propertyName);
+ if ("localization".equals(property.getPropertyType())) {
+ // localization-_= is a localization entry for
+ // for the with
+ for (Entry localizationValues : propertyHolder.localizationValues.entrySet()) {
+ writeableProperties.setProperty(LOCALIZATION_PREFIX + SEPERATOR
+ + localizationValues.getKey().toLanguageTag() + SEPERATOR + propertyName,
+ localizationValues.getValue());
+ }
+ } else if (property.getPropertyType().startsWith("connection")) {
+ // TODO don't write connection information until security parameters can be
+ // hammered out
+ } else {
+ writeableProperties.setProperty(propertyName,
+ (propertyHolder == null || propertyHolder.getValue() == null) ? ""
+ : propertyHolder.getValue());
+ }
+ } else {
+ writeableProperties.setProperty(propertyName,
+ (propertyHolder == null || propertyHolder.getValue() == null) ? "" : propertyHolder.getValue());
+ }
+ }
+
+ public String getProperty(String name) {
+ if (allProperties.containsKey(name)) {
+ return allProperties.get(name).getValue();
+ } else {
+ LogEvent.logWarn(this.getClass().getSimpleName(), "getProperty",
+ "getting property that doesn't exist yet '" + name + "'");
+ return null;
+ }
+ }
+
+ public Set stringPropertyNames() {
+ return allProperties.keySet();
+ }
+
+ public boolean containsKey(String key) {
+ return allProperties.containsKey(key);
+ }
+
}
+
}
diff --git a/src/main/java/org/openelisglobal/common/util/SystemConfiguration.java b/src/main/java/org/openelisglobal/common/util/SystemConfiguration.java
deleted file mode 100644
index 0180bddff1..0000000000
--- a/src/main/java/org/openelisglobal/common/util/SystemConfiguration.java
+++ /dev/null
@@ -1,964 +0,0 @@
-/**
- * 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) The Minnesota Department of Health. All Rights Reserved.
- *
- *
Contributor(s): CIRG, University of Washington, Seattle WA.
- */
-package org.openelisglobal.common.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import org.apache.commons.validator.GenericValidator;
-import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.ConfigurationProperties.Property;
-import org.openelisglobal.internationalization.MessageUtil;
-
-/** This class represents the configuration properties of the application */
-public class SystemConfiguration {
-
- private static final String propertyFile = "/SystemConfiguration.properties";
-
- private static class SingletonHelper {
- private static final SystemConfiguration INSTANCE = new SystemConfiguration();
- }
-
- private List localChangeListeners = new ArrayList<>();
-
- private Properties properties = null;
- private Map localePropertyToLocaleMap = new HashMap<>();
-
- private SystemConfiguration() {
- InputStream propertyStream = null;
-
- try {
- propertyStream = this.getClass().getResourceAsStream(propertyFile);
-
- // Now load a java.util.Properties object with the properties
- properties = new Properties();
-
- properties.load(propertyStream);
-
- } catch (IOException e) {
- // bugzilla 2154
- LogEvent.logError(e);
- } finally {
- if (null != propertyStream) {
- try {
- propertyStream.close();
- } catch (IOException e) {
- // bugzilla 2154
- LogEvent.logError(e);
- }
- }
- }
- }
-
- public static SystemConfiguration getInstance() {
- return SingletonHelper.INSTANCE;
- }
-
- public void addLocalChangeListener(LocaleChangeListener listener) {
- localChangeListeners.add(listener);
- }
-
- public int getDefaultPageSize() {
- String pageSize = properties.getProperty("page.defaultPageSize");
- if (pageSize != null) {
- return Integer.parseInt(pageSize);
- }
- // bugzilla 1409
- return 20;
- }
-
- // bugzilla 1742
- public int getDefaultTreePageSize() {
- String pageSize = properties.getProperty("page.tree.defaultPageSize");
- if (pageSize != null) {
- return Integer.parseInt(pageSize);
- }
- return 10;
- }
-
- // bugzilla 1742
- public int getDefaultPaginatedNodeChildCount() {
- String count = properties.getProperty("page.tree.paginatednode.child.count");
- if (count != null) {
- return Integer.parseInt(count);
- }
- return 32;
- }
-
- public Locale getDefaultLocale() {
- return getLocaleByLocalString(
- ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE));
- }
-
- public Locale getLocaleByLocalString(String localeString) {
- Locale locale = localePropertyToLocaleMap.get(localeString);
-
- if (locale == null) {
- if (localeString != null && localeString.length() == 5) {
- locale = new Locale(localeString.substring(0, 2), localeString.substring(3));
- localePropertyToLocaleMap.put(localeString, locale);
- }
- }
-
- return locale == null ? Locale.US : locale;
- }
-
- public void setDefaultLocale(String locale) {
- ConfigurationProperties.getInstance().setPropertyValue(Property.DEFAULT_LANG_LOCALE, locale);
- for (LocaleChangeListener listener : localChangeListeners) {
- listener.localeChanged(locale);
- }
- }
-
- public String getDefaultEncoding() {
- String encodingString = properties.getProperty("default.encoding");
- if (encodingString != null) {
- return encodingString;
- }
- return "Cp1252";
- }
-
- public String getDefaultApplicationName() {
- String applicationNameString = properties.getProperty("default.application.name");
- if (applicationNameString != null) {
- return applicationNameString;
- }
- // bugzilla 1995
- return "OpenELIS";
- }
-
- public String getDefaultIdSeparator() {
- String def = properties.getProperty("default.idSeparator");
- if (def != null) {
- return def;
- }
- return ";";
- }
-
- public String getDefaultTextSeparator() {
- String def = properties.getProperty("default.textSeparator");
- if (def != null) {
- return def;
- }
- return "|;|";
- }
-
- public String getDictionaryType() {
- String dictType = properties.getProperty("dictionaryType");
- if (dictType != null) {
- return dictType;
- }
- return "D";
- }
-
- public String getTiterType() {
- String titerType = properties.getProperty("titerType");
- if (titerType != null) {
- return titerType;
- }
- return "T";
- }
-
- public String getAnalyteTypeRequired() {
- String analyteTypeRequired = properties.getProperty("analyteTypeRequired");
- if (analyteTypeRequired != null) {
- return analyteTypeRequired;
- }
- return "R";
- }
-
- public String getAnalyteTypeNotRequired() {
- String analyteTypeNotRequired = properties.getProperty("analyteTypeNotRequired");
- if (analyteTypeNotRequired != null) {
- return analyteTypeNotRequired;
- }
- return "N";
- }
-
- public String getNumericType() {
- String numericType = properties.getProperty("numericType");
- if (numericType != null) {
- return numericType;
- }
- return "N";
- }
- // ==============================================================
-
- public String getQuickEntryDefaultReferredCultureFlag() {
- String def = properties.getProperty("quickEntry.default.sample.referredCultureFlag");
- if (def != null) {
- return def;
- }
- return "S";
- }
-
- public String getQuickEntryDefaultStickerReceivedFlag() {
- String def = properties.getProperty("quickEntry.default.sample.stickerReceivedFlag");
- if (def != null) {
- return def;
- }
- return "N";
- }
-
- public String getQuickEntryDefaultNextItemSequence() {
- String def = properties.getProperty("quickEntry.default.sample.nextItemSequence");
- if (def != null) {
- return def;
- }
- return "1";
- }
-
- public String getQuickEntryDefaultRevision() {
- String def = properties.getProperty("quickEntry.default.sample.revision");
- if (def != null) {
- return def;
- }
- return "0";
- }
-
- public String getQuickEntryDefaultCollectionTimeForDisplay() {
- String def = properties.getProperty("quickEntry.default.sample.collectionTimeForDisplay");
- if (def != null) {
- return def;
- }
- return "00:00";
- }
- // ==============================================================
-
- public String getHumanSampleOneDefaultReferredCultureFlag() {
- String def = properties.getProperty("humanSampleOne.default.sample.referredCultureFlag");
- if (def != null) {
- return def;
- }
- // bugzilla 1754 - blank is default
- return "";
- }
-
- public String getHumanSampleOneDefaultStickerReceivedFlag() {
- String def = properties.getProperty("humanSampleOne.default.sample.stickerReceivedFlag");
- if (def != null) {
- return def;
- }
- return "N";
- }
-
- public String getHumanSampleOneDefaultNextItemSequence() {
- String def = properties.getProperty("humanSampleOne.default.sample.nextItemSequence");
- if (def != null) {
- return def;
- }
- return "1";
- }
-
- public String getHumanSampleOneDefaultRevision() {
- String def = properties.getProperty("humanSampleOne.default.sample.revision");
- if (def != null) {
- return def;
- }
- return "0";
- }
-
- public String getHumanSampleOneDefaultCollectionTimeForDisplay() {
- String def = properties.getProperty("humanSampleOne.default.sample.collectionTimeForDisplay");
- if (def != null) {
- return def;
- }
- return "00:00";
- }
-
- public String getHumanSampleOneDefaultPatientGender() {
- String def = properties.getProperty("humanSampleOne.default.patient.gender");
- if (def != null) {
- return def;
- }
- return "";
- }
-
- // bugzilla 1387 rename this method so more generic
- public String getHumanDomain() {
- String def = properties.getProperty("domain.human");
- if (def != null) {
- return def;
- }
- return "H";
- }
-
- // bugzilla 1387 rename this method so more generic
- public String getAnimalDomain() {
- String def = properties.getProperty("domain.animal");
- if (def != null) {
- return def;
- }
- return "A";
- }
-
- // bugzilla 1348 - analysis status for verification
- public String getAnalysisVerifiedStatus() {
- String def = properties.getProperty("analysis.status.verified");
- if (def != null) {
- return def;
- }
- return "V";
- }
-
- // bugzilla 1348 - analysis status for verification
- public String getAnalysisReadyToVerifyStatus() {
- String def = properties.getProperty("analysis.status.readytoverify");
- if (def != null) {
- return def;
- }
- return "";
- }
-
- // bugzilla - reports id
- public String getOpenReportsReportId(String key) {
- String def = properties.getProperty(key);
- if (def != null) {
- return def;
- }
- return "";
- }
-
- // bugzilla - reports group
- public String getOpenReportsGroupId(String key) {
- String def = properties.getProperty(key);
- if (def != null) {
- return def;
- }
- return "";
- }
-
- // bugzilla 1546
- public String getSampleStatusType() {
- String def = properties.getProperty("sample.status");
- if (def != null) {
- return def;
- }
- return "";
- }
-
- public String getAnalysisStatusType() {
- String def = properties.getProperty("analysis.status");
- if (def != null) {
- return def;
- }
- return "";
- }
-
- // bugzilla 2380
- public String getLabelPrinterName() {
- String printer = properties.getProperty("print.label.name");
- if (printer != null) {
- return printer;
- }
- return "";
- }
-
- public String getLabelNumberOfCopies(String key) {
- String numberOfCopies = properties.getProperty(key);
- if (numberOfCopies != null) {
- return numberOfCopies;
- }
- return "1";
- }
-
- // bugzilla 2374
- public String getMaxNumberOfLabels() {
- String maxNumberOfLabels = properties.getProperty("print.label.numeroflabels");
- if (maxNumberOfLabels != null) {
- return maxNumberOfLabels;
- }
- return "100";
- }
-
- public String getBarcodeHeight() {
- String height = properties.getProperty("print.label.barcode.height");
- if (height != null) {
- return height;
- }
- return "44";
- }
-
- public String getBarcodeWidth() {
- String width = properties.getProperty("print.label.barcode.width");
- if (width != null) {
- return width;
- }
- return "330";
- }
-
- public String getBarcodeResolution() {
- String res = properties.getProperty("print.label.barcode.resolution");
- if (res != null) {
- return res;
- }
- return "300";
- }
-
- // bugzilla 2592
- public String getDefaultSampleLabel(String accessionNumber) {
- String prependBarcode = properties.getProperty("print.label.sample.prepend.barcode");
- String prependHumanReadable = properties.getProperty("print.label.sample.prepend.humanreadable");
- String postpend = properties.getProperty("print.label.sample.postpend");
- if (prependBarcode != null && prependHumanReadable != null && postpend != null) {
- int sampleLabelLength = prependBarcode.length() + accessionNumber.length() + prependHumanReadable.length()
- + accessionNumber.length() + postpend.length();
- StringBuffer sb = new StringBuffer(sampleLabelLength);
- sb.append(prependBarcode).append(accessionNumber).append(prependHumanReadable).append(accessionNumber)
- .append(postpend);
- return sb.toString();
- }
- return "";
- }
-
- public String getAnalysisStatusAssigned() {
- String val = properties.getProperty("analysis.status.assigned");
- if (val != null) {
- return val;
- }
-
- return "1";
- }
-
- // bugzilla 2300
- public String getAnalysisStatusCanceled() {
- String val = properties.getProperty("analysis.status.canceled");
- if (val != null) {
- return val;
- }
-
- return "2";
- }
-
- public String getAnalysisStatusResultCompleted() {
- String val = properties.getProperty("analysis.status.result.completed");
- if (val != null) {
- return val;
- }
-
- return "3";
- }
-
- public String getAnalysisStatusReleased() {
- String val = properties.getProperty("analysis.status.released");
- if (val != null) {
- return val;
- }
-
- return "4";
- }
-
- public String getSampleStatusQuickEntryComplete() {
- String val = properties.getProperty("sample.status.quick.entry.complete");
- if (val != null) {
- return val;
- }
-
- return "1";
- }
-
- public String getSampleStatusEntry1Complete() {
- String val = properties.getProperty("sample.status.entry.1.complete");
- if (val != null) {
- return val;
- }
-
- return "2";
- }
-
- public String getSampleStatusEntry2Complete() {
- String val = properties.getProperty("sample.status.entry.2.complete");
- if (val != null) {
- return val;
- }
-
- return "3";
- }
-
- public String getSampleStatusReleased() {
- String val = properties.getProperty("sample.status.released");
- if (val != null) {
- return val;
- }
-
- return "7";
- }
-
- public String getSampleStatusLabelPrinted() {
- String val = properties.getProperty("sample.status.label.printed");
- if (val != null) {
- return val;
- }
-
- return "8";
- }
-
- public String getOpenReportsSwitchModulePath() {
- String res = properties.getProperty("openreports.switch.module.path");
- if (res != null) {
- return res;
- }
- return "../../openreports";
- }
-
- public String getResultReferenceTableId() {
- String refId = properties.getProperty("result.reference.table.id");
- if (refId != null) {
- return refId;
- }
- return "21";
- }
-
- // bugzilla 2028
- public String getAnalysisQaEventActionReferenceTableId() {
- String refId = properties.getProperty("analysis.qaevent.action.reference.table.id");
- if (refId != null) {
- return refId;
- }
- return "21";
- }
-
- // bugzilla 2500
- public String getSampleQaEventActionReferenceTableId() {
- String refId = properties.getProperty("sample.qaevent.action.reference.table.id");
- if (refId != null) {
- return refId;
- }
- return "21";
- }
-
- public String getNoteTypeInternal() {
- String internalType = properties.getProperty("note.type.internal");
- if (internalType != null) {
- return internalType;
- }
- return "I";
- }
-
- public String getNoteTypeExternal() {
- String externalType = properties.getProperty("note.type.external");
- if (externalType != null) {
- return externalType;
- }
- return "I";
- }
-
- public String getDefaultTransportMethodForXMLTransmission() {
- String transportMethod = properties.getProperty("default.transport.method");
- if (transportMethod != null) {
- return transportMethod;
- }
- return "PHINMS_DEFINED_IN_SYS_CONFIG";
- }
-
- public String getDefaultProcessingIdForXMLTransmission() {
- String processingId = properties.getProperty("default.transport.processing.id");
- if (processingId != null) {
- return processingId;
- }
- return "T_DEFINED_IN_SYS_CONFIG";
- }
-
- public String getDefaultTransmissionTextSeparator() {
- String separator = properties.getProperty("default.transport.text.separator");
- if (separator != null) {
- return separator;
- }
- return "^_DEFINED_IN_SYS_CONFIG";
- }
-
- public String getDefaultTransmissionCodeSystemType() {
- String codeSystemType = properties.getProperty("default.transport.code.system.type");
- if (codeSystemType != null) {
- return codeSystemType;
- }
- return "L";
- }
-
- public String getMdhUhlIdForXMLTransmission() {
- String uhlId = properties.getProperty("mdh.uhl.id");
- if (uhlId != null) {
- return uhlId;
- }
- return "9999__DEFINED_IN_SYS_CONFIG";
- }
-
- public String getMdhUniversalIdForXMLTransmission() {
- String universalId = properties.getProperty("mdh.universal.id");
- if (universalId != null) {
- return universalId;
- }
- return "9999__DEFINED_IN_SYS_CONFIG";
- }
-
- public String getMdhUniversalIdTypeForXMLTransmission() {
- String universalIdType = properties.getProperty("mdh.universal.id.type");
- if (universalIdType != null) {
- return universalIdType;
- }
- return "9999__DEFINED_IN_SYS_CONFIG";
- }
-
- public String getMdhPhoneNumberForXMLTransmission() {
- String phoneNumber = properties.getProperty("mdh.work.phone");
- if (phoneNumber != null) {
- return phoneNumber;
- }
- return "800/999-9999_DEFINED_IN_SYS_CONFIG";
- }
-
- public String getMdhOrganizationIdForXMLTransmission() {
- String orgId = properties.getProperty("mdh.organization.record.id");
- if (orgId != null) {
- return orgId;
- }
- return "43";
- }
-
- // bugzilla 2393 INFLUENZA XML
- public String getInfluenzaDefaultProcessingIdForXMLTransmission() {
- String processingId = properties.getProperty("default.transport.processing.id.influenza");
- if (processingId != null) {
- return processingId;
- }
- return "T";
- }
-
- // bugzilla 2393
- public String getInfluenzaDefaultApplicationName() {
- String applicationNameString = properties.getProperty("default.application.name.influenza");
- if (applicationNameString != null) {
- return applicationNameString;
- }
- // bugzilla 1995
- return "MN OpenELIS Stage";
- }
-
- // 1742 openreports static ids (tests, projects etc.)
- public String getStaticIdByName(String name) {
- String testId = properties.getProperty(name);
- // LogEvent.logInfo(this.getClass().getSimpleName(), "method unkown",
- // "SystemConfig
- // getting test by name " + name);
- if (testId != null) {
- return testId;
- }
- return "";
- }
-
- public String getDefaultDataSource() {
- String dsString = properties.getProperty("default.datasource");
- if (dsString != null) {
- return dsString;
- }
- return "LimsDS";
- }
-
- // bugzilla 2028 get qaevent code for quickentry sample type NOT GIVEN
- public String getQaEventCodeForRequestNoSampleType() {
- String string = properties.getProperty("qaeventcode.request.sourcemissing");
- if (string != null) {
- return string;
- }
- return "RQNSO";
- }
-
- // bugzilla 2028 get qaevent code for quickentry missing collection date
- public String getQaEventCodeForRequestNoCollectionDate() {
- String string = properties.getProperty("qaeventcode.request.collectiondatemissing");
- if (string != null) {
- return string;
- }
- return "RQNCD";
- }
-
- // bugzilla 2028 get qaevent code for quickentry submitter unknown
- public String getQaEventCodeForRequestUnknownSubmitter() {
- String string = properties.getProperty("qaeventcode.request.submitterunknown");
- if (string != null) {
- return string;
- }
- return "RQNSNA";
- }
-
- // bugzilla 2028 get unknownSubmitterNumber
- // bugzilla 2589 unknown submitter number is null now
- public String getUnknownSubmitterNumberForQaEvent() {
- String string = properties.getProperty("unknown.submitter.number");
- if (string != null) {
- return string;
- }
- return "";
- }
-
- // bugzilla 2028 get qaevent action code for quickentry sample type NOT GIVEN
- public String getQaEventActionCodeForRequestNoSampleType() {
- String string = properties.getProperty("qaeventactioncode.request.sourcemissing");
- if (string != null) {
- return string;
- }
- return "RQSOC";
- }
-
- // bugzilla 2028 get qaevent action code for quickentry missing collection date
- public String getQaEventActionCodeForRequestNoCollectionDate() {
- String string = properties.getProperty("qaeventactioncode.request.collectiondatemissing");
- if (string != null) {
- return string;
- }
- return "CDC";
- }
-
- // bugzilla 2028 get qaevent action code for quickentry submitter unknown
- public String getQaEventActionCodeForRequestUnknownSubmitter() {
- String string = properties.getProperty("qaeventactioncode.request.submitterunknown");
- if (string != null) {
- return string;
- }
- return "SNAC";
- }
-
- // bugzilla 2063
- public String getQaEventDictionaryCategoryType() {
- String string = properties.getProperty("dictionary.category.qaevent.type");
- if (string != null) {
- return string;
- }
- // bugzilla 2221 - we are now defining only exceptions to the rule
- return "Q";
- }
-
- // bugzilla 2506
- public String getQaEventDictionaryCategoryCategory() {
- String string = properties.getProperty("dictionary.category.qaevent.category");
- if (string != null) {
- return string;
- }
- // bugzilla 2221 - we are now defining only exceptions to the rule
- return "QC";
- }
-
- public String getLoginUserChangePasswordAllowDay() {
- String string = properties.getProperty("login.user.change.allow.day");
- if (string != null) {
- return string;
- }
- return "3";
- }
-
- public String getLoginUserChangePasswordExpiredMonth() {
- String string = properties.getProperty("login.user.expired.month");
- if (string != null) {
- return string;
- }
- return "1";
- }
-
- // bugzilla 2286 password reminder days
- public String getLoginUserPasswordExpiredReminderDay() {
- String string = properties.getProperty("login.user.expired.reminder.day");
- if (string != null) {
- return string;
- }
- return "15";
- }
-
- // bugzilla 2286 account lock after 3 failed logins
- public String getLoginUserFailAttemptCount() {
- String string = properties.getProperty("login.fail.attempt.count");
- if (string != null) {
- return string;
- }
- return "3";
- }
-
- // bugzilla 2286 account unlock after 10 minutes
- public String getLoginUserAccountUnlockMinute() {
- String string = properties.getProperty("login.user.account.unlock.minute");
- if (string != null) {
- return string;
- }
- return "10";
- }
-
- // User Test Section
- public String getEnableUserTestSection() {
- String string = properties.getProperty("enable.user.test.section");
- if (string != null) {
- return string;
- }
- return "Y";
- }
-
- public String getAnalysisDefaultRevision() {
- String def = properties.getProperty("analysis.default.revision");
- if (def != null) {
- return def;
- }
- return "0";
- }
-
- // Encrypted PDF Path
- public String getEncryptedPdfPath() {
- String string = properties.getProperty("encrypted.pdf.path");
- if (string != null) {
- return string;
- }
- return "/export/project/phl/scans";
- }
-
- // Allow to view the encrypted pdf
- public String getEnabledSamplePdf() {
- String string = properties.getProperty("enable.sample.pdf");
- if (string != null) {
- return string;
- }
- return "Y";
- }
-
- // bugzilla 2528
- public String getNewbornTestPanelName() {
- String string = properties.getProperty("newborn.testPanelName");
- if (string != null) {
- return string;
- }
- return "NBS-Panel";
- }
-
- public String getNewbornTypeOfSample() {
- String string = properties.getProperty("newborn.typeOfSample");
- if (string != null) {
- return string;
- }
- return "DRIED BLOOD SPOT CARD";
- }
-
- // bugzilla 2529, 2530
- public String getNewbornDomain() {
- String string = properties.getProperty("domain.newborn");
- if (string != null) {
- return string;
- }
- return "N";
- }
-
- // for testing only to inject values
- public void setSiteCode(String siteCode) {
- properties.setProperty("sitecode", siteCode);
- }
-
- public String getProgramCodes() {
- String codes = properties.getProperty("programcodes");
-
- return (codes == null ? "" : codes);
- }
-
- // for testing only to inject values
- public void setProgramCodes(String programCodes) {
- properties.setProperty("programcodes", programCodes);
- }
-
- public String getNewbornPatientRelation() {
- String string = properties.getProperty("newborn.patient.relation");
- if (string != null) {
- return string;
- }
- return "M";
- }
-
- // we are letting the date locale differ from the default locale. Not a good
- // thing
- public Locale getDateLocale() {
- String localeString = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_DATE_LOCALE);
- Locale locale = Locale.US;
-
- if (!GenericValidator.isBlankOrNull(localeString)) {
- String[] splitLocale = localeString.split("-");
-
- if (splitLocale.length == 1) { // there is variation around separators
- splitLocale = localeString.split("_");
- }
-
- switch (splitLocale.length) {
- case 1: {
- locale = new Locale(splitLocale[0]);
- break;
- }
- case 2: {
- locale = new Locale(splitLocale[0], splitLocale[1]);
- break;
- }
- case 3: {
- locale = new Locale(splitLocale[0], splitLocale[1], splitLocale[2]);
- break;
- }
- default: // no-op
- }
- }
- return locale;
- }
-
- public String getPatternForDateLocale() {
- Locale locale = getLocaleByLocalString(
- ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_DATE_LOCALE));
- return MessageUtil.getMessage("date.format.formatKey", locale).toUpperCase();
- // DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT,
- // getDateLocale());
- // // yyyy/mm/dd
- // Date date = Date.valueOf("2000-01-02");
- // String pattern = dateFormat.format(date);
- // pattern = pattern.replaceFirst("01", "MM");
- // pattern = pattern.replaceFirst("02", "DD");
- // pattern = pattern.replaceFirst("00", "YYYY");
- // return pattern;
- }
-
- public boolean errorsToScreen() {
- String id = properties.getProperty("errors.to.screen");
- return id == null ? false : Boolean.valueOf(id.trim());
- }
-
- public String getPermissionAgent() {
- return properties.getProperty("permissions.agent", "USER").trim().toUpperCase();
- }
-
- public long getSearchTimeLimit() {
- long limit = 20000L;
- String timeLimit = properties.getProperty("patient.search.time.limit.ms");
- if (!GenericValidator.isBlankOrNull(timeLimit)) {
- try {
- limit = Long.parseLong(timeLimit);
- } catch (NumberFormatException e) {
- LogEvent.logError(
- "Invalid SystemConfiguration format for 'patient.search.time.limit.ms'. Default used", e);
- }
- }
- return limit;
- }
-
- public boolean useTestPatientGUID() {
- return "enable".equals(properties.getProperty("use.test.patient.guid", "disable"));
- }
-
- public void setProperty(String property, String value) {
- properties.setProperty(property, value);
- }
-}
diff --git a/src/main/java/org/openelisglobal/common/util/validator/CustomDateValidator.java b/src/main/java/org/openelisglobal/common/util/validator/CustomDateValidator.java
index 1daed8f144..e562849b46 100644
--- a/src/main/java/org/openelisglobal/common/util/validator/CustomDateValidator.java
+++ b/src/main/java/org/openelisglobal/common/util/validator/CustomDateValidator.java
@@ -23,7 +23,8 @@
import org.apache.commons.validator.routines.DateValidator;
import org.openelisglobal.common.action.IActionConstants;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
+import org.openelisglobal.common.util.ConfigurationProperties.Property;
public class CustomDateValidator extends DateValidator {
@@ -111,7 +112,8 @@ public boolean isValid(String value, Locale locale) {
}
public Date getDate(String date) {
- Locale locale = SystemConfiguration.getInstance().getDateLocale();
+ Locale locale = Locale
+ .forLanguageTag(ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_DATE_LOCALE));
return validate(date, locale);
}
diff --git a/src/main/java/org/openelisglobal/config/AppConfig.java b/src/main/java/org/openelisglobal/config/AppConfig.java
index 7c20d63287..3ce52b2162 100644
--- a/src/main/java/org/openelisglobal/config/AppConfig.java
+++ b/src/main/java/org/openelisglobal/config/AppConfig.java
@@ -9,7 +9,6 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
-import java.util.Locale;
import java.util.Properties;
import org.apache.commons.validator.GenericValidator;
import org.hl7.fhir.r4.model.Questionnaire;
@@ -34,7 +33,6 @@
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.Scope;
-import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.http.converter.HttpMessageConverter;
@@ -58,6 +56,10 @@
@PropertySource("classpath:application.properties")
@PropertySource("file:/run/secrets/common.properties")
@PropertySource(value = "file:/run/secrets/extra.properties", ignoreResourceNotFound = true)
+@PropertySource(value = "classpath:SystemConfiguration.properties", ignoreResourceNotFound = true)
+@PropertySource(value = "file:/var/lib/openelis-global/properties/SystemConfiguration.properties", ignoreResourceNotFound = true)
+@PropertySource(value = "file:/var/lib/openelis-global/properties/TotalSystemConfiguration.properties", ignoreResourceNotFound = true)
+@PropertySource(value = "file:/var/lib/openelis-global/properties/SystemConfiguration.properties", ignoreResourceNotFound = true)
@ComponentScan(basePackages = { "spring", "org.openelisglobal", "org.itech", "org.ozeki.sms", "oe.plugin" })
public class AppConfig implements WebMvcConfigurer {
@@ -161,9 +163,6 @@ public JavaMailSender getJavaMailSender() {
// functionality
public LocaleResolver localeResolver() {
GlobalLocaleResolver localeResolver = new GlobalLocaleResolver();
- String localeName = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
- localeResolver.setDefaultLocale(Locale.forLanguageTag(localeName));
- LocaleContextHolder.setDefaultLocale(Locale.forLanguageTag(localeName));
return localeResolver;
}
diff --git a/src/main/java/org/openelisglobal/dataexchange/fhir/service/FhirTransformServiceImpl.java b/src/main/java/org/openelisglobal/dataexchange/fhir/service/FhirTransformServiceImpl.java
index e1293da7ad..d3cbbd662a 100644
--- a/src/main/java/org/openelisglobal/dataexchange/fhir/service/FhirTransformServiceImpl.java
+++ b/src/main/java/org/openelisglobal/dataexchange/fhir/service/FhirTransformServiceImpl.java
@@ -193,6 +193,9 @@ public void initializeGlobalVariables() {
@Async
@Override
public AsyncResult transformPersistPatients(List patientIds) throws FhirLocalPersistingException {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformPersistPatients",
+ "transformPersistPatients called");
+
FhirOperations fhirOperations = new FhirOperations();
CountingTempIdGenerator tempIdGenerator = new CountingTempIdGenerator();
@@ -223,6 +226,9 @@ public AsyncResult transformPersistPatients(List patientIds) thr
@Override
public AsyncResult transformPersistObjectsUnderSamples(List sampleIds)
throws FhirLocalPersistingException {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformPersistObjectsUnderSamples",
+ "transformPersistObjectsUnderSamples called");
+
FhirOperations fhirOperations = new FhirOperations();
CountingTempIdGenerator tempIdGenerator = new CountingTempIdGenerator();
@@ -385,6 +391,8 @@ public AsyncResult transformPersistObjectsUnderSamples(List samp
@Transactional(readOnly = true)
public void transformPersistPatient(PatientManagementInfo patientInfo, boolean isCreate)
throws FhirLocalPersistingException {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformPersistPatient", "transformPersistPatient called");
+
CountingTempIdGenerator tempIdGenerator = new CountingTempIdGenerator();
FhirOperations fhirOperations = new FhirOperations();
org.hl7.fhir.r4.model.Patient patient = transformToFhirPatient(patientInfo.getPatientPK());
@@ -417,6 +425,9 @@ public void transformPersistPatient(PatientManagementInfo patientInfo, boolean i
@Async
@Override
public void transformPersistOrganization(Organization organization) throws FhirLocalPersistingException {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformPersistOrganization",
+ "transformPersistOrganization called");
+
CountingTempIdGenerator tempIdGenerator = new CountingTempIdGenerator();
FhirOperations fhirOperations = new FhirOperations();
org.hl7.fhir.r4.model.Organization fhirOrg = transformToFhirOrganization(organization);
@@ -430,6 +441,8 @@ public void transformPersistOrganization(Organization organization) throws FhirL
public void transformPersistOrderEntryFhirObjects(SamplePatientUpdateData updateData,
PatientManagementInfo patientInfo, boolean useReferral, List referralItems)
throws FhirLocalPersistingException {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformPersistOrderEntryFhirObjects",
+ "transformPersistOrderEntryFhirObjects called");
LogEvent.logTrace(this.getClass().getSimpleName(), "createFhirFromSamplePatient",
"accessionNumber - " + updateData.getAccessionNumber());
CountingTempIdGenerator tempIdGenerator = new CountingTempIdGenerator();
@@ -504,6 +517,9 @@ public void transformPersistOrderEntryFhirObjects(SamplePatientUpdateData update
}
private void updateReferringTaskWithTaskInfo(Task referringTask, Task task) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "updateReferringTaskWithTaskInfo",
+ "updateReferringTaskWithTaskInfo called");
+
if (TaskStatus.COMPLETED.equals(task.getStatus())) {
referringTask.setStatus(TaskStatus.COMPLETED);
task.getOutput().forEach(outPut -> {
@@ -513,6 +529,9 @@ private void updateReferringTaskWithTaskInfo(Task referringTask, Task task) {
}
private void updateReferringServiceRequestWithSampleInfo(Sample sample, ServiceRequest serviceRequest) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "updateReferringServiceRequestWithSampleInfo",
+ "updateReferringServiceRequestWithSampleInfo called");
+
if (!serviceRequest.hasRequisition()) {
serviceRequest.setRequisition(
this.createIdentifier(fhirConfig.getOeFhirSystem() + "/samp_labNo", sample.getAccessionNumber()));
@@ -520,6 +539,9 @@ private void updateReferringServiceRequestWithSampleInfo(Sample sample, ServiceR
}
private Optional getReferringTaskForSample(Sample sample) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "getReferringTaskForSample",
+ "getReferringTaskForSample called");
+
List eOrders = electronicOrderService.getElectronicOrdersByExternalId(sample.getReferringId());
if (eOrders.size() > 0 && ElectronicOrderType.FHIR.equals(eOrders.get(0).getType())) {
return fhirPersistanceService.getTaskBasedOnServiceRequest(sample.getReferringId());
@@ -528,6 +550,9 @@ private Optional getReferringTaskForSample(Sample sample) {
}
private Optional getReferringServiceRequestForSample(Sample sample) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "getReferringServiceRequestForSample",
+ "getReferringServiceRequestForSample called");
+
List eOrders = electronicOrderService.getElectronicOrdersByExternalId(sample.getReferringId());
if (eOrders.size() > 0 && ElectronicOrderType.FHIR.equals(eOrders.get(0).getType())) {
return fhirPersistanceService.getServiceRequestByReferingId(sample.getReferringId());
@@ -541,6 +566,9 @@ private Practitioner transformProviderToPractitioner(String providerId) {
@Override
public Practitioner transformProviderToPractitioner(Provider provider) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformProviderToPractitioner",
+ "transformProviderToPractitioner called");
+
Practitioner practitioner = new Practitioner();
practitioner.setId(provider.getFhirUuidAsString());
practitioner.addIdentifier(
@@ -554,6 +582,8 @@ public Practitioner transformProviderToPractitioner(Provider provider) {
}
private List transformToTelecom(Person person) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToTelecom", "transformToTelecom called");
+
List contactPoints = new ArrayList<>();
if (person.getPrimaryPhone() != null) {
contactPoints.add(new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(person.getPrimaryPhone())
@@ -576,6 +606,8 @@ private Task transformToTask(String sampleId) {
}
private Task transformToTask(Sample sample) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToTask", "transformToTask called");
+
Task task = new Task();
Patient patient = sampleHumanService.getPatientForSample(sample);
List analysises = sampleService.getAnalysis(sample);
@@ -624,6 +656,12 @@ private Task transformToTask(Sample sample) {
}
private DateType transformToDateElement(String strDate) throws ParseException {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToDateElement", "transformToDateElement called");
+
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToDateElement", "transforming date " + strDate);
+ if (GenericValidator.isBlankOrNull(strDate)) {
+ return null;
+ }
boolean dayAmbiguous = false;
boolean monthAmbiguous = false;
// TODO look at this logic for detecting ambiguity
@@ -654,12 +692,18 @@ public org.hl7.fhir.r4.model.Patient transformToFhirPatient(String patientId) {
}
private org.hl7.fhir.r4.model.Patient transformToFhirPatient(Patient patient) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToFhirPatient", "transformToFhirPatient called");
+
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToFhirPatient",
+ "transforming patient with id: " + patient.getId());
org.hl7.fhir.r4.model.Patient fhirPatient = new org.hl7.fhir.r4.model.Patient();
String subjectNumber = patientService.getSubjectNumber(patient);
String nationalId = patientService.getNationalId(patient);
String guid = patientService.getGUID(patient);
String stNumber = patientService.getSTNumber(patient);
String uuid = patient.getFhirUuidAsString();
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToFhirPatient",
+ "transforming patient with id: " + patient.getId() + " fhirUuid: " + uuid);
fhirPatient.setId(uuid);
fhirPatient.setIdentifier(createPatientIdentifiers(subjectNumber, nationalId, stNumber, guid, uuid));
@@ -677,7 +721,7 @@ private org.hl7.fhir.r4.model.Patient transformToFhirPatient(Patient patient) {
fhirPatient.setBirthDateElement(transformToDateElement(patient.getBirthDateForDisplay()));
}
} catch (ParseException e) {
- LogEvent.logError("patient date unparseable " + patient.getBirthDateForDisplay(), e);
+ LogEvent.logError("patient date unparseable '" + patient.getBirthDateForDisplay() + "'", e);
}
if (GenericValidator.isBlankOrNull(patient.getGender())) {
fhirPatient.setGender(AdministrativeGender.UNKNOWN);
@@ -752,6 +796,8 @@ public PatientSearchResults transformToOpenElisPatientSearchResults(org.hl7.fhir
}
private Address transformToAddress(Person person) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToAddress", "transformToAddress called");
+
@SuppressWarnings("unused")
PersonAddress village = null;
PersonAddress commune = null;
@@ -784,6 +830,8 @@ private Address transformToAddress(Person person) {
private List createPatientIdentifiers(String subjectNumber, String nationalId, String stNumber,
String guid, String fhirUuid) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToAddress", "transformToAddress called");
+
List identifierList = new ArrayList<>();
if (!GenericValidator.isBlankOrNull(subjectNumber)) {
identifierList.add(createIdentifier(fhirConfig.getOeFhirSystem() + "/pat_subjectNumber", subjectNumber));
@@ -805,6 +853,9 @@ private List createPatientIdentifiers(String subjectNumber, String n
private List transformToServiceRequests(SamplePatientUpdateData updateData,
SampleTestCollection sampleTestCollection) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToServiceRequests",
+ "transformToServiceRequests called");
+
List serviceRequestsForSampleItem = new ArrayList<>();
for (Analysis analysis : sampleTestCollection.analysises) {
@@ -818,6 +869,9 @@ private ServiceRequest transformToServiceRequest(String anlaysisId) {
}
private ServiceRequest transformToServiceRequest(Analysis analysis) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToServiceRequest",
+ "transformToServiceRequest called");
+
Sample sample = analysis.getSampleItem().getSample();
Patient patient = sampleHumanService.getPatientForSample(sample);
Provider provider = sampleHumanService.getProviderForSample(sample);
@@ -894,6 +948,9 @@ private ServiceRequest transformToServiceRequest(Analysis analysis) {
}
private CodeableConcept transformSampleProgramToCodeableConcept(ObservationHistory program) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformSampleProgramToCodeableConcept",
+ "transformSampleProgramToCodeableConcept called");
+
CodeableConcept codeableConcept = new CodeableConcept();
String programDisplay = "";
String programCode = "";
@@ -917,6 +974,9 @@ private CodeableConcept transformTestToCodeableConcept(String testId) {
}
private CodeableConcept transformTestToCodeableConcept(Test test) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformTestToCodeableConcept",
+ "transformTestToCodeableConcept test called");
+
CodeableConcept codeableConcept = new CodeableConcept();
codeableConcept
.addCoding(new Coding("http://loinc.org", test.getLoinc(), test.getLocalizedTestName().getEnglish()));
@@ -924,6 +984,8 @@ private CodeableConcept transformTestToCodeableConcept(Test test) {
}
private Specimen transformToFhirSpecimen(SampleTestCollection sampleTest) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToFhirSpecimen", "transformToFhirSpecimen called");
+
Specimen specimen = this.transformToSpecimen(sampleTest.item.getId());
if (sampleTest.initialSampleConditionIdList != null) {
for (ObservationHistory initialSampleCondition : sampleTest.initialSampleConditionIdList) {
@@ -939,6 +1001,8 @@ private Specimen transformToSpecimen(String sampleItemId) {
}
private Specimen transformToSpecimen(SampleItem sampleItem) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToSpecimen", "transformToSpecimen called");
+
Specimen specimen = new Specimen();
Patient patient = sampleHumanService.getPatientForSample(sampleItem.getSample());
specimen.setId(sampleItem.getFhirUuidAsString());
@@ -965,6 +1029,9 @@ private CodeableConcept transformSampleConditionToCodeableConcept(String sampleC
}
private CodeableConcept transformSampleConditionToCodeableConcept(ObservationHistory initialSampleCondition) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformSampleConditionToCodeableConcept",
+ "transformSampleConditionToCodeableConcept called");
+
String observationValue;
String observationDisplay;
if (ValueType.DICTIONARY.getCode().equals(initialSampleCondition.getValueType())) {
@@ -985,6 +1052,8 @@ private CodeableConcept transformSampleConditionToCodeableConcept(ObservationHis
}
private SpecimenCollectionComponent transformToCollection(Timestamp collectionDate, String collector) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToCollection", "transformToCollection called");
+
SpecimenCollectionComponent specimenCollectionComponent = new SpecimenCollectionComponent();
specimenCollectionComponent.setCollected(new DateTimeType(collectionDate));
// TODO create a collector from this info
@@ -997,6 +1066,9 @@ private CodeableConcept transformTypeOfSampleToCodeableConcept(String typeOfSamp
}
private CodeableConcept transformTypeOfSampleToCodeableConcept(TypeOfSample typeOfSample) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformTypeOfSampleToCodeableConcept",
+ "transformTypeOfSampleToCodeableConcept called");
+
CodeableConcept codeableConcept = new CodeableConcept();
codeableConcept.addCoding(new Coding(fhirConfig.getOeFhirSystem() + "/sampleType",
typeOfSample.getLocalAbbreviation(), typeOfSample.getLocalizedName()));
@@ -1008,6 +1080,9 @@ private CodeableConcept transformTypeOfSampleToCodeableConcept(TypeOfSample type
@Transactional(readOnly = true)
public void transformPersistResultsEntryFhirObjects(ResultsUpdateDataSet actionDataSet)
throws FhirLocalPersistingException {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformPersistResultsEntryFhirObjects",
+ "transformPersistResultsEntryFhirObjects called");
+
CountingTempIdGenerator tempIdGenerator = new CountingTempIdGenerator();
FhirOperations fhirOperations = new FhirOperations();
for (ResultSet resultSet : actionDataSet.getNewResults()) {
@@ -1037,6 +1112,9 @@ public void transformPersistResultsEntryFhirObjects(ResultsUpdateDataSet actionD
public void transformPersistResultValidationFhirObjects(List deletableList,
List analysisUpdateList, ArrayList resultUpdateList, List resultItemList,
ArrayList sampleUpdateList, ArrayList noteUpdateList) throws FhirLocalPersistingException {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformPersistResultValidationFhirObjects",
+ "transformPersistResultValidationFhirObjects called");
+
CountingTempIdGenerator tempIdGenerator = new CountingTempIdGenerator();
FhirOperations fhirOperations = new FhirOperations();
@@ -1100,15 +1178,17 @@ public void transformPersistResultValidationFhirObjects(List deletableLi
}
private void addToOperations(FhirOperations fhirOperations, TempIdGenerator tempIdGenerator, Resource resource) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "addToOperations", "addToOperations called");
+
if (this.setTempIdIfMissing(resource, tempIdGenerator)) {
if (fhirOperations.createResources.containsKey(resource.getIdElement().getIdPart())) {
- LogEvent.logError("", "",
+ LogEvent.logWarn("", "",
"collision on id: " + resource.getResourceType() + "/" + resource.getIdElement().getIdPart());
}
fhirOperations.createResources.put(resource.getIdElement().getIdPart(), resource);
} else {
if (fhirOperations.updateResources.containsKey(resource.getIdElement().getIdPart())) {
- LogEvent.logError("", "",
+ LogEvent.logWarn("", "",
"collision on id: " + resource.getResourceType() + "/" + resource.getIdElement().getIdPart());
}
fhirOperations.updateResources.put(resource.getIdElement().getIdPart(), resource);
@@ -1120,6 +1200,9 @@ private DiagnosticReport transformResultToDiagnosticReport(String analysisId) {
}
private DiagnosticReport transformResultToDiagnosticReport(Analysis analysis) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformResultToDiagnosticReport",
+ "transformResultToDiagnosticReport called");
+
List allResults = resultService.getResultsByAnalysis(analysis);
SampleItem sampleItem = analysis.getSampleItem();
Patient patient = sampleHumanService.getPatientForSample(sampleItem.getSample());
@@ -1153,6 +1236,8 @@ private DiagnosticReport transformResultToDiagnosticReport(Analysis analysis) {
}
private DiagnosticReport genNewDiagnosticReport(Analysis analysis) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "genNewDiagnosticReport", "genNewDiagnosticReport called");
+
DiagnosticReport diagnosticReport = new DiagnosticReport();
diagnosticReport.setId(analysis.getFhirUuidAsString());
diagnosticReport.addIdentifier(this.createIdentifier(fhirConfig.getOeFhirSystem() + "/analysisResult_uuid",
@@ -1165,6 +1250,9 @@ private Observation transformResultToObservation(String resultId) {
}
private Observation transformResultToObservation(Result result) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformResultToObservation",
+ "transformResultToObservation called");
+
Analysis analysis = result.getAnalysis();
Test test = analysis.getTest();
SampleItem sampleItem = analysis.getSampleItem();
@@ -1238,6 +1326,9 @@ private Observation transformResultToObservation(Result result) {
@Override
public Practitioner transformNameToPractitioner(String practitionerName) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformNameToPractitioner",
+ "transformNameToPractitioner called");
+
Practitioner practitioner = new Practitioner();
HumanName name = practitioner.addName();
@@ -1262,6 +1353,9 @@ public Practitioner transformNameToPractitioner(String practitionerName) {
@Override
@Transactional(readOnly = true)
public org.hl7.fhir.r4.model.Organization transformToFhirOrganization(Organization organization) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToFhirOrganization",
+ "transformToFhirOrganization called");
+
org.hl7.fhir.r4.model.Organization fhirOrganization = new org.hl7.fhir.r4.model.Organization();
fhirOrganization
.setId(organization.getFhirUuid() == null ? organization.getId() : organization.getFhirUuidAsString());
@@ -1276,6 +1370,8 @@ public org.hl7.fhir.r4.model.Organization transformToFhirOrganization(Organizati
@Override
@Transactional(readOnly = true)
public Organization transformToOrganization(org.hl7.fhir.r4.model.Organization fhirOrganization) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformToOrganization", "transformToOrganization called");
+
Organization organization = new Organization();
organization.setOrganizationName(fhirOrganization.getName());
organization.setIsActive(Boolean.FALSE == fhirOrganization.getActiveElement().getValue() ? IActionConstants.NO
@@ -1293,6 +1389,9 @@ public Organization transformToOrganization(org.hl7.fhir.r4.model.Organization f
private void setOeOrganizationIdentifiers(Organization organization,
org.hl7.fhir.r4.model.Organization fhirOrganization) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "setOeOrganizationIdentifiers",
+ "setOeOrganizationIdentifiers called");
+
organization.setFhirUuid(UUID.fromString(fhirOrganization.getIdElement().getIdPart()));
for (Identifier identifier : fhirOrganization.getIdentifier()) {
if (identifier.getSystem().equals(fhirConfig.getOeFhirSystem() + "/org_cliaNum")) {
@@ -1309,6 +1408,9 @@ private void setOeOrganizationIdentifiers(Organization organization,
private void setFhirOrganizationIdentifiers(org.hl7.fhir.r4.model.Organization fhirOrganization,
Organization organization) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "setFhirOrganizationIdentifiers",
+ "setFhirOrganizationIdentifiers called");
+
if (!GenericValidator.isBlankOrNull(organization.getCliaNum())) {
fhirOrganization.addIdentifier(new Identifier().setSystem(fhirConfig.getOeFhirSystem() + "/org_cliaNum")
.setValue(organization.getCliaNum()));
@@ -1329,6 +1431,8 @@ private void setFhirOrganizationIdentifiers(org.hl7.fhir.r4.model.Organization f
private void setOeOrganizationTypes(Organization organization,
org.hl7.fhir.r4.model.Organization fhirOrganization) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "setOeOrganizationTypes", "setOeOrganizationTypes called");
+
Set orgTypes = new HashSet<>();
OrganizationType orgType = null;
for (CodeableConcept type : fhirOrganization.getType()) {
@@ -1350,6 +1454,9 @@ private void setOeOrganizationTypes(Organization organization,
private void setFhirOrganizationTypes(org.hl7.fhir.r4.model.Organization fhirOrganization,
Organization organization) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "setFhirOrganizationTypes",
+ "setFhirOrganizationTypes called");
+
Set orgTypes = organizationService.get(organization.getId()).getOrganizationTypes();
for (OrganizationType orgType : orgTypes) {
fhirOrganization.addType(new CodeableConcept() //
@@ -1362,6 +1469,9 @@ private void setFhirOrganizationTypes(org.hl7.fhir.r4.model.Organization fhirOrg
private void setOeOrganizationAddressInfo(Organization organization,
org.hl7.fhir.r4.model.Organization fhirOrganization) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "setOeOrganizationAddressInfo",
+ "setOeOrganizationAddressInfo called");
+
organization.setStreetAddress(fhirOrganization.getAddressFirstRep().getLine().stream()
.map(e -> e.asStringValue()).collect(Collectors.joining("\\n")));
organization.setCity(fhirOrganization.getAddressFirstRep().getCity());
@@ -1370,6 +1480,8 @@ private void setOeOrganizationAddressInfo(Organization organization,
}
private void setFhirAddressInfo(org.hl7.fhir.r4.model.Organization fhirOrganization, Organization organization) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "setFhirAddressInfo", "setFhirAddressInfo called");
+
if (!GenericValidator.isBlankOrNull(organization.getStreetAddress())) {
fhirOrganization.getAddressFirstRep().addLine(organization.getStreetAddress());
}
@@ -1385,6 +1497,9 @@ private void setFhirAddressInfo(org.hl7.fhir.r4.model.Organization fhirOrganizat
}
private Annotation transformNoteToAnnotation(Note note) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "transformNoteToAnnotation",
+ "transformNoteToAnnotation called");
+
Annotation annotation = new Annotation();
annotation.setText(note.getText());
return annotation;
@@ -1392,6 +1507,8 @@ private Annotation transformNoteToAnnotation(Note note) {
@Override
public boolean setTempIdIfMissing(Resource resource, TempIdGenerator tempIdGenerator) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "setTempIdIfMissing", "setTempIdIfMissing called");
+
if (GenericValidator.isBlankOrNull(resource.getId())) {
resource.setId(tempIdGenerator.getNextId());
return true;
@@ -1401,6 +1518,8 @@ public boolean setTempIdIfMissing(Resource resource, TempIdGenerator tempIdGener
@Override
public Reference createReferenceFor(Resource resource) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "createReferenceFor", "createReferenceFor called");
+
if (resource == null) {
return null;
}
@@ -1411,6 +1530,8 @@ public Reference createReferenceFor(Resource resource) {
@Override
public Reference createReferenceFor(ResourceType resourceType, String id) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "createReferenceFor", "createReferenceFor called");
+
if (GenericValidator.isBlankOrNull(id)) {
LogEvent.logWarn(this.getClass().getName(), "createReferenceFor",
"null or empty id used in resource:" + resourceType + "/" + id);
@@ -1422,6 +1543,8 @@ public Reference createReferenceFor(ResourceType resourceType, String id) {
@Override
public String getIdFromLocation(String location) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "getIdFromLocation", "getIdFromLocation called");
+
String id = location.substring(location.indexOf("/") + 1);
while (id.lastIndexOf("/") > 0) {
id = id.substring(0, id.lastIndexOf("/"));
@@ -1431,6 +1554,8 @@ public String getIdFromLocation(String location) {
@Override
public Identifier createIdentifier(String system, String value) {
+ LogEvent.logTrace(this.getClass().getSimpleName(), "createIdentifier", "createIdentifier called");
+
Identifier identifier = new Identifier();
identifier.setValue(value);
diff --git a/src/main/java/org/openelisglobal/dataexchange/resultreporting/ResultReportingCollator.java b/src/main/java/org/openelisglobal/dataexchange/resultreporting/ResultReportingCollator.java
index b40ffbb6cc..d4a5e690e3 100644
--- a/src/main/java/org/openelisglobal/dataexchange/resultreporting/ResultReportingCollator.java
+++ b/src/main/java/org/openelisglobal/dataexchange/resultreporting/ResultReportingCollator.java
@@ -348,17 +348,6 @@ private TestResultsXmit getResultsWrapperForPatient(String patientId, boolean pr
GUID_IDENTITY_TYPE);
}
- // Everything between these comments are for testing only and should be remove
- // beforE they go into production
- // if (SystemConfiguration.getInstance().useTestPatientGUID() && patientIdentity
- // == null) {
- // patientIdentity = new PatientIdentity();
- // patientIdentity.setIdentityData(UUID.randomUUID().toString());
- // patientIdentity.setIdentityTypeId(GUID_IDENTITY_TYPE);
- // patientIdentity.setPatientId(patientId);
- // }
- // End of testing comment
-
if (patientIdentity == null) {
noGUIDPatients.add(patientId);
return null;
diff --git a/src/main/java/org/openelisglobal/dictionary/controller/DictionaryController.java b/src/main/java/org/openelisglobal/dictionary/controller/DictionaryController.java
index b95d0eacdd..576320d1b4 100644
--- a/src/main/java/org/openelisglobal/dictionary/controller/DictionaryController.java
+++ b/src/main/java/org/openelisglobal/dictionary/controller/DictionaryController.java
@@ -13,8 +13,8 @@
import org.openelisglobal.common.form.BaseForm;
import org.openelisglobal.common.log.LogEvent;
import org.openelisglobal.common.services.DisplayListService;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.validator.BaseErrors;
import org.openelisglobal.common.validator.ValidationHelper;
import org.openelisglobal.dictionary.form.DictionaryForm;
@@ -245,7 +245,8 @@ private boolean checkForDictionaryFrozenCheck(DictionaryForm form) {
String dirtyFormFields = form.getDirtyFormFields();
String isActiveValue = form.getIsActive();
- String[] dirtyFields = dirtyFormFields.split(SystemConfiguration.getInstance().getDefaultIdSeparator(), -1);
+ String[] dirtyFields = dirtyFormFields
+ .split(ConfigurationProperties.getInstance().getPropertyValue("default.idSeparator"), -1);
List listOfDirtyFields = new ArrayList<>();
for (int i = 0; i < dirtyFields.length; i++) {
diff --git a/src/main/java/org/openelisglobal/dictionary/controller/DictionaryMenuController.java b/src/main/java/org/openelisglobal/dictionary/controller/DictionaryMenuController.java
index 8fee1c9d29..144ee4e4d9 100644
--- a/src/main/java/org/openelisglobal/dictionary/controller/DictionaryMenuController.java
+++ b/src/main/java/org/openelisglobal/dictionary/controller/DictionaryMenuController.java
@@ -10,7 +10,7 @@
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.form.AdminOptionMenuForm;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.validator.BaseErrors;
import org.openelisglobal.dictionary.form.DictionaryMenuForm;
import org.openelisglobal.dictionary.service.DictionaryService;
@@ -84,8 +84,10 @@ protected List createMenuList(AdminOptionMenuForm form,
request.setAttribute(MENU_TOTAL_RECORDS, String.valueOf(total));
request.setAttribute(MENU_FROM_RECORD, String.valueOf(startingRecNo));
int numOfRecs = 0;
- if (dictionaries.size() > SystemConfiguration.getInstance().getDefaultPageSize()) {
- numOfRecs = SystemConfiguration.getInstance().getDefaultPageSize();
+ if (dictionaries.size() > Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))) {
+ numOfRecs = Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
} else {
numOfRecs = dictionaries.size();
}
@@ -109,7 +111,7 @@ protected List createMenuList(AdminOptionMenuForm form,
@Override
protected int getPageSize() {
- return SystemConfiguration.getInstance().getDefaultPageSize();
+ return Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
}
@Override
diff --git a/src/main/java/org/openelisglobal/dictionary/controller/rest/DictionaryMenuRestController.java b/src/main/java/org/openelisglobal/dictionary/controller/rest/DictionaryMenuRestController.java
index aaaa7ab437..69a2ca7b7e 100644
--- a/src/main/java/org/openelisglobal/dictionary/controller/rest/DictionaryMenuRestController.java
+++ b/src/main/java/org/openelisglobal/dictionary/controller/rest/DictionaryMenuRestController.java
@@ -10,7 +10,7 @@
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.form.AdminOptionMenuForm;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.validator.BaseErrors;
import org.openelisglobal.dictionary.form.DictionaryMenuForm;
import org.openelisglobal.dictionary.service.DictionaryService;
@@ -128,8 +128,10 @@ protected List createMenuList(AdminOptionMenuForm form,
request.setAttribute(MENU_FROM_RECORD, String.valueOf(startingRecNo));
int numOfRecs = 0;
- if (dictionaries.size() > SystemConfiguration.getInstance().getDefaultPageSize()) {
- numOfRecs = SystemConfiguration.getInstance().getDefaultPageSize();
+ if (dictionaries.size() > Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))) {
+ numOfRecs = Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
} else {
numOfRecs = dictionaries.size();
}
diff --git a/src/main/java/org/openelisglobal/dictionary/controller/rest/DictionaryRestController.java b/src/main/java/org/openelisglobal/dictionary/controller/rest/DictionaryRestController.java
index 99e4023edf..563cc8ba5a 100644
--- a/src/main/java/org/openelisglobal/dictionary/controller/rest/DictionaryRestController.java
+++ b/src/main/java/org/openelisglobal/dictionary/controller/rest/DictionaryRestController.java
@@ -15,8 +15,8 @@
import org.openelisglobal.common.form.BaseForm;
import org.openelisglobal.common.log.LogEvent;
import org.openelisglobal.common.services.DisplayListService;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.validator.BaseErrors;
import org.openelisglobal.common.validator.ValidationHelper;
import org.openelisglobal.dictionary.form.DictionaryForm;
@@ -256,7 +256,8 @@ private boolean checkForDictionaryFrozenCheck(DictionaryForm form) {
String dirtyFormFields = form.getDirtyFormFields();
String isActiveValue = form.getIsActive();
- String[] dirtyFields = dirtyFormFields.split(SystemConfiguration.getInstance().getDefaultIdSeparator(), -1);
+ String[] dirtyFields = dirtyFormFields
+ .split(ConfigurationProperties.getInstance().getPropertyValue("default.idSeparator"), -1);
List listOfDirtyFields = new ArrayList<>();
for (int i = 0; i < dirtyFields.length; i++) {
diff --git a/src/main/java/org/openelisglobal/dictionary/daoimpl/DictionaryDAOImpl.java b/src/main/java/org/openelisglobal/dictionary/daoimpl/DictionaryDAOImpl.java
index fe84ebc211..91f57117df 100644
--- a/src/main/java/org/openelisglobal/dictionary/daoimpl/DictionaryDAOImpl.java
+++ b/src/main/java/org/openelisglobal/dictionary/daoimpl/DictionaryDAOImpl.java
@@ -25,8 +25,8 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.valueholder.BaseObject;
import org.openelisglobal.dictionary.dao.DictionaryDAO;
import org.openelisglobal.dictionary.valueholder.Dictionary;
@@ -217,8 +217,8 @@ public boolean isDictionaryFrozen(Dictionary dictionary) throws LIMSRuntimeExcep
// to check those here also check references from other tables depending on
// dictionary
// category local abbrev code
- if (dictionary.getDictionaryCategory().getLocalAbbreviation()
- .equals(SystemConfiguration.getInstance().getQaEventDictionaryCategoryType())) {
+ if (dictionary.getDictionaryCategory().getLocalAbbreviation().equals(
+ ConfigurationProperties.getInstance().getPropertyValue("dictionary.category.qaevent.type"))) {
sql = "from QaEvent q where q.type = :param";
// bugzilla 2221: at this time there are only 2 categories as
// far as this isFrozen() logic:
diff --git a/src/main/java/org/openelisglobal/dictionary/validator/DictionaryFormValidator.java b/src/main/java/org/openelisglobal/dictionary/validator/DictionaryFormValidator.java
index 0f9e6285ee..e0bd58bc56 100644
--- a/src/main/java/org/openelisglobal/dictionary/validator/DictionaryFormValidator.java
+++ b/src/main/java/org/openelisglobal/dictionary/validator/DictionaryFormValidator.java
@@ -1,6 +1,6 @@
package org.openelisglobal.dictionary.validator;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.validator.ValidationHelper;
import org.openelisglobal.dictionary.form.DictionaryForm;
import org.springframework.stereotype.Component;
@@ -20,7 +20,7 @@ public void validate(Object target, Errors errors) {
DictionaryForm form = (DictionaryForm) target;
String[] dirtyFields = form.getDirtyFormFields()
- .split(SystemConfiguration.getInstance().getDefaultIdSeparator(), -1);
+ .split(ConfigurationProperties.getInstance().getPropertyValue("default.idSeparator"), -1);
for (String dirtyField : dirtyFields) {
ValidationHelper.validateFieldAndCharset(dirtyField, "dirtyFormField", errors, false, 255, "a-zA-Z0-9_");
if (errors.hasErrors()) {
diff --git a/src/main/java/org/openelisglobal/externalconnections/controller/ExternalConnectionController.java b/src/main/java/org/openelisglobal/externalconnections/controller/ExternalConnectionController.java
index f3e6c03377..619411f607 100644
--- a/src/main/java/org/openelisglobal/externalconnections/controller/ExternalConnectionController.java
+++ b/src/main/java/org/openelisglobal/externalconnections/controller/ExternalConnectionController.java
@@ -129,7 +129,7 @@ public ModelAndView addEditExternalConnection(@Valid @ModelAttribute("form") Ext
externalConnectionService.updateExternalConnection(externalConnectionAuthData, externalConnectionContacts,
externalConnection);
}
- ConfigurationProperties.forceReload();
+ ConfigurationProperties.loadDBValuesIntoConfiguration();
return findForward(FWD_SUCCESS_INSERT, form);
}
diff --git a/src/main/java/org/openelisglobal/externalconnections/dao/BasicAuthenticationDataDAOImpl.java b/src/main/java/org/openelisglobal/externalconnections/dao/BasicAuthenticationDataDAOImpl.java
index 10b38fc4af..020cf9bba7 100644
--- a/src/main/java/org/openelisglobal/externalconnections/dao/BasicAuthenticationDataDAOImpl.java
+++ b/src/main/java/org/openelisglobal/externalconnections/dao/BasicAuthenticationDataDAOImpl.java
@@ -21,6 +21,9 @@ public BasicAuthenticationDataDAOImpl() {
@Override
public Optional getByExternalConnection(Integer externalConnectionId) {
+ if (externalConnectionId == null) {
+ return Optional.empty();
+ }
BasicAuthenticationData data;
try {
String sql = "from BasicAuthenticationData as cad where cad.externalConnection.id ="
diff --git a/src/main/java/org/openelisglobal/fhir/transormation/controller/FhirTransformationController.java b/src/main/java/org/openelisglobal/fhir/transormation/controller/FhirTransformationController.java
index 71d9bc2af6..599e010def 100644
--- a/src/main/java/org/openelisglobal/fhir/transormation/controller/FhirTransformationController.java
+++ b/src/main/java/org/openelisglobal/fhir/transormation/controller/FhirTransformationController.java
@@ -5,7 +5,6 @@
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import javax.servlet.http.HttpServletResponse;
import org.hl7.fhir.r4.model.Bundle;
import org.itech.fhir.dataexport.api.service.DataExportService;
import org.itech.fhir.dataexport.core.model.DataExportTask;
@@ -21,11 +20,11 @@
import org.openelisglobal.samplehuman.service.SampleHumanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
-@Controller
+@RestController
public class FhirTransformationController extends BaseController {
@Autowired
private SampleService sampleService;
@@ -39,22 +38,38 @@ public class FhirTransformationController extends BaseController {
@Autowired
private DataExportTaskService dataExportTaskService;
- private static boolean running = false;
+ // global variable for tracking state as only one process can be run at a time
+ private TransformationInfo info;
@Scheduled(initialDelay = 10 * 1000, fixedRate = Long.MAX_VALUE)
- private void transformOEObjectsOnBoot() {
- transformPersistFhirObjects(false, 100, 1);
+ private void transformOEObjectsOnBoot() throws FhirLocalPersistingException, IOException {
+ transformPersistMissingFhirObjects(false, 100, 1, true);
+ }
+
+ @GetMapping("/OEToFhir/info")
+ public TransformationInfo getTransformationInfo() throws FhirLocalPersistingException, IOException {
+ return info;
}
@GetMapping("/PatientToFhir")
- public void transformPersistFhirPatients(@RequestParam(defaultValue = "false") Boolean checkAll,
+ public TransformationInfo transformPersistFhirPatients(@RequestParam(defaultValue = "false") Boolean checkAll,
@RequestParam(defaultValue = "100") int batchSize, @RequestParam(defaultValue = "1") int threads,
- HttpServletResponse response) throws FhirLocalPersistingException, IOException {
+ @RequestParam(defaultValue = "true") boolean waitForResults)
+ throws FhirLocalPersistingException, IOException {
+ if (inProcess()) {
+ LogEvent.logWarn(this.getClass().getSimpleName(), "transformPersistFhirPatients",
+ "processs already running");
+ return info;
+ }
+ info.checkAll = checkAll;
+ info.batchSize = batchSize;
+ info.threads = threads;
+ info.waitForResults = waitForResults;
+ info.objectType = "Patient";
+ info.phase = "Fetching";
List patients;
- int batches = 0;
- int batchFailure = 0;
- if (checkAll) {
+ if (info.checkAll) {
patients = sampleHumanService.getAllPatientsWithSampleEntered();
} else {
patients = sampleHumanService.getAllPatientsWithSampleEnteredMissingFhirUuid();
@@ -63,64 +78,72 @@ public void transformPersistFhirPatients(@RequestParam(defaultValue = "false") B
"patients to convert: " + patients.size());
List patientIds = new ArrayList<>();
List> promises = new ArrayList<>();
+ info.objectType = "Patient";
for (int i = 0; i < patients.size(); ++i) {
+ info.phase = "Batch Transforming";
patientIds.add(patients.get(i).getId());
- if (i % batchSize == batchSize - 1 || i + 1 == patients.size()) {
+ if (i % info.batchSize == info.batchSize - 1 || i + 1 == patients.size()) {
LogEvent.logDebug(this.getClass().getSimpleName(), "",
- "persisting batch " + (i - batchSize + 1) + "-" + i + " of " + patients.size());
+ "persisting batch " + (i - info.batchSize + 1) + "-" + i + " of " + patients.size());
try {
promises.add(fhirTransformService.transformPersistPatients(patientIds));
- ++batches;
+ ++info.batches;
patientIds = new ArrayList<>();
- if (promises.size() >= threads || i + 1 == patients.size()) {
+ if (info.waitForResults && (promises.size() >= info.threads || i + 1 == patients.size())) {
waitForResults(promises);
promises = new ArrayList<>();
}
} catch (FhirPersistanceException e) {
- ++batchFailure;
+ ++info.batchFailure;
LogEvent.logError(e);
LogEvent.logError(this.getClass().getSimpleName(), "transformPersistFhirPatients",
- "error persisting batch " + (i - batchSize + 1) + "-" + i);
+ "error persisting batch " + (i - info.batchSize + 1) + "-" + i);
} catch (Exception e) {
- ++batchFailure;
+ ++info.batchFailure;
LogEvent.logError(e);
LogEvent.logError(this.getClass().getSimpleName(), "transformPersistFhirPatients",
- "error with batch " + (i - batchSize + 1) + "-" + i);
+ "error with batch " + (i - info.batchSize + 1) + "-" + i);
} finally {
- if (promises.size() >= threads || i + 1 == patients.size()) {
+ if (promises.size() >= info.threads || i + 1 == patients.size()) {
promises = new ArrayList<>();
}
}
}
}
+ info.phase = "Finished";
LogEvent.logDebug(this.getClass().getSimpleName(), "transformPersistFhirPatients", "finished all batches");
- response.getWriter().println("patient batches total: " + batches);
- response.getWriter().println("patient batches failed: " + batchFailure);
+ return info;
}
@GetMapping("/OEToFhir")
- public void transformPersistMissingFhirObjects(@RequestParam(defaultValue = "false") Boolean checkAll,
+ public TransformationInfo transformPersistMissingFhirObjects(@RequestParam(defaultValue = "false") Boolean checkAll,
@RequestParam(defaultValue = "100") int batchSize, @RequestParam(defaultValue = "1") int threads,
- HttpServletResponse response) throws FhirLocalPersistingException, IOException {
+ @RequestParam(defaultValue = "true") boolean waitForResults)
+ throws FhirLocalPersistingException, IOException {
if (inProcess()) {
LogEvent.logWarn(this.getClass().getSimpleName(), "transformPersistMissingFhirObjects",
"processs already running");
- response.getWriter().println("processs already running");
- return;
+ return info;
}
- BatchResult result = transformPersistFhirObjects(checkAll, batchSize, threads);
+ info.checkAll = checkAll;
+ info.batchSize = batchSize;
+ info.threads = threads;
+ info.waitForResults = waitForResults;
+
+ transformPersistFhirObjects();
- response.getWriter().println("sample batches total: " + result.batches);
- response.getWriter().println("sample batches failed: " + result.batchFailure);
+ return info;
}
- private BatchResult transformPersistFhirObjects(Boolean checkAll, int batchSize, int threads) {
+ private void transformPersistFhirObjects() {
try {
+ info.objectType = "Patient";
+ info.phase = "Fetching";
List patients;
- if (checkAll) {
+ if (info.checkAll) {
patients = sampleHumanService.getAllPatientsWithSampleEntered();
} else {
patients = sampleHumanService.getAllPatientsWithSampleEnteredMissingFhirUuid();
@@ -129,31 +152,35 @@ private BatchResult transformPersistFhirObjects(Boolean checkAll, int batchSize,
"patients to convert: " + patients.size());
List patientIds = new ArrayList<>();
List> promises = new ArrayList<>();
+ info.objectType = "Patient";
for (int i = 0; i < patients.size(); ++i) {
+ info.phase = "Batch Transforming";
patientIds.add(patients.get(i).getId());
- if (i % batchSize == batchSize - 1 || i + 1 == patients.size()) {
+ if (i % info.batchSize == info.batchSize - 1 || i + 1 == patients.size()) {
LogEvent.logDebug(this.getClass().getSimpleName(), "",
- "persisting batch " + (i - batchSize + 1) + "-" + i + " of " + patients.size());
+ "persisting batch " + (i - info.batchSize + 1) + "-" + i + " of " + patients.size());
try {
promises.add(fhirTransformService.transformPersistPatients(patientIds));
patientIds = new ArrayList<>();
- if (promises.size() >= threads || i + 1 == patients.size()) {
+ if (info.waitForResults && (promises.size() >= info.threads || i + 1 == patients.size())) {
waitForResults(promises);
}
} catch (FhirPersistanceException e) {
LogEvent.logError(e);
LogEvent.logError(this.getClass().getSimpleName(), "transformPersistMissingFhirObjects",
- "error persisting batch " + (i - batchSize + 1) + "-" + i);
+ "error persisting batch " + (i - info.batchSize + 1) + "-" + i);
} catch (Exception e) {
LogEvent.logError(e);
LogEvent.logError(this.getClass().getSimpleName(), "transformPersistMissingFhirObjects",
- "error with batch " + (i - batchSize + 1) + "-" + i);
+ "error with batch " + (i - info.batchSize + 1) + "-" + i);
}
}
}
+ info.objectType = "Sample";
+ info.phase = "Fetching";
List samples;
- if (checkAll) {
+ if (info.checkAll) {
samples = sampleService.getAll();
} else {
samples = sampleService.getAllMissingFhirUuid();
@@ -161,42 +188,37 @@ private BatchResult transformPersistFhirObjects(Boolean checkAll, int batchSize,
LogEvent.logDebug(this.getClass().getSimpleName(), "transformPersistMissingFhirObjects",
"samples to convert: " + samples.size());
- int batches = 0;
- int batchFailure = 0;
List sampleIds = new ArrayList<>();
promises = new ArrayList<>();
for (int i = 0; i < samples.size(); ++i) {
+ info.phase = "Batch Transforming";
sampleIds.add(samples.get(i).getId());
- if (i % batchSize == batchSize - 1 || i + 1 == samples.size()) {
+ if (i % info.batchSize == info.batchSize - 1 || i + 1 == samples.size()) {
LogEvent.logDebug(this.getClass().getSimpleName(), "",
- "persisting batch " + (i - batchSize + 1) + "-" + i + " of " + samples.size());
+ "persisting batch " + (i - info.batchSize + 1) + "-" + i + " of " + samples.size());
try {
promises.add(fhirTransformService.transformPersistObjectsUnderSamples(sampleIds));
- ++batches;
+ ++info.batches;
sampleIds = new ArrayList<>();
- if (promises.size() >= threads) {
+ if (info.waitForResults && (promises.size() >= info.threads || i + 1 == samples.size())) {
waitForResults(promises);
}
} catch (FhirPersistanceException e) {
- ++batchFailure;
+ ++info.batchFailure;
LogEvent.logError(e);
LogEvent.logError(this.getClass().getSimpleName(), "transformPersistMissingFhirObjects",
- "error persisting batch " + (i - batchSize + 1) + "-" + i);
+ "error persisting batch " + (i - info.batchSize + 1) + "-" + i);
} catch (Exception e) {
- ++batchFailure;
+ ++info.batchFailure;
LogEvent.logError(e);
LogEvent.logError(this.getClass().getSimpleName(), "transformPersistMissingFhirObjects",
- "error with batch " + (i - batchSize + 1) + "-" + i);
+ "error with batch " + (i - info.batchSize + 1) + "-" + i);
}
}
}
LogEvent.logDebug(this.getClass().getSimpleName(), "transformPersistMissingFhirObjects",
"finished all batches");
-
- BatchResult result = new BatchResult();
- result.batchFailure = batchFailure;
- result.batches = batches;
- return result;
+ info.phase = "Finished";
} catch (RuntimeException e) {
throw e;
} finally {
@@ -205,6 +227,10 @@ private BatchResult transformPersistFhirObjects(Boolean checkAll, int batchSize,
}
private void waitForResults(List> promises) throws Exception {
+ LogEvent.logDebug(this.getClass().getSimpleName(), "", "waiting for results from "
+ + (promises.size() == 1 ? promises.size() + " thread" : promises.size() + " threads"));
+
+ info.phase = "Waiting on Threads";
for (int i = promises.size() - 1; i >= 0; i--) {
try {
promises.remove(i).get();
@@ -244,19 +270,27 @@ protected String getPageSubtitleKey() {
}
private synchronized boolean inProcess() {
- if (!running) {
- running = true;
+ if (info == null || !info.running) {
+ info = new TransformationInfo();
+ info.running = true;
return false;
}
return true;
}
private synchronized void endProcess() {
- running = false;
+ info.running = false;
}
- class BatchResult {
+ public class TransformationInfo {
+ public boolean running;
public int batches;
public int batchFailure;
+ public String objectType;
+ public String phase;
+ public int batchSize;
+ public int threads; // ignored if waitForResults is false
+ public boolean checkAll;
+ public boolean waitForResults;
}
}
diff --git a/src/main/java/org/openelisglobal/hibernate/converter/URIConverter.java b/src/main/java/org/openelisglobal/hibernate/converter/URIConverter.java
index 856d63a164..c75cebf82b 100644
--- a/src/main/java/org/openelisglobal/hibernate/converter/URIConverter.java
+++ b/src/main/java/org/openelisglobal/hibernate/converter/URIConverter.java
@@ -11,11 +11,17 @@ public class URIConverter implements AttributeConverter {
@Override
public String convertToDatabaseColumn(URI uri) {
+ if (uri == null) {
+ return null;
+ }
return uri.toString();
}
@Override
public URI convertToEntityAttribute(String dbData) {
+ if (dbData == null) {
+ return null;
+ }
try {
return new URI(dbData);
} catch (URISyntaxException e) {
diff --git a/src/main/java/org/openelisglobal/interceptor/CommonPageAttributesInterceptor.java b/src/main/java/org/openelisglobal/interceptor/CommonPageAttributesInterceptor.java
index 961de9f76b..8929275a9b 100644
--- a/src/main/java/org/openelisglobal/interceptor/CommonPageAttributesInterceptor.java
+++ b/src/main/java/org/openelisglobal/interceptor/CommonPageAttributesInterceptor.java
@@ -8,6 +8,7 @@
import org.openelisglobal.common.log.LogEvent;
import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.ConfigurationProperties.Property;
+import org.openelisglobal.common.util.DefaultConfigurationProperties;
import org.openelisglobal.localization.service.LocalizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -18,15 +19,17 @@
public class CommonPageAttributesInterceptor implements HandlerInterceptor {
@Autowired
- LocalizationService localizationService;
+ private LocalizationService localizationService;
+ @Autowired
+ private DefaultConfigurationProperties configurationProprties;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
request.setAttribute("title", localizationService.getLocalizedValueById(
- ConfigurationProperties.getInstance().getPropertyValue(ConfigurationProperties.Property.BANNER_TEXT)));
+ configurationProprties.getPropertyValue(ConfigurationProperties.Property.BANNER_TEXT)));
request.setAttribute("oeTitle", localizationService
- .getLocalizedValueById(ConfigurationProperties.getInstance().getPropertyValue(Property.BANNER_TEXT)));
+ .getLocalizedValueById(configurationProprties.getPropertyValue(Property.BANNER_TEXT)));
return true;
}
@@ -43,7 +46,7 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response,
String actionName = name.substring(1, name.length() - 4);
actionName = name.substring(0, 1).toUpperCase() + actionName;
request.setAttribute(IActionConstants.ACTION_KEY, actionName);
- LogEvent.logDebug("PageAttributesInterceptor", "postHandle()",
+ LogEvent.logTrace("PageAttributesInterceptor", "postHandle()",
"PageAttributesInterceptor formName = " + name + " actionName " + actionName);
}
}
diff --git a/src/main/java/org/openelisglobal/interceptor/ModuleAuthenticationInterceptor.java b/src/main/java/org/openelisglobal/interceptor/ModuleAuthenticationInterceptor.java
index a84e2fc2e6..60bf205625 100644
--- a/src/main/java/org/openelisglobal/interceptor/ModuleAuthenticationInterceptor.java
+++ b/src/main/java/org/openelisglobal/interceptor/ModuleAuthenticationInterceptor.java
@@ -8,7 +8,7 @@
import javax.servlet.http.HttpServletResponse;
import org.openelisglobal.common.action.IActionConstants;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.validator.BaseErrors;
import org.openelisglobal.login.dao.UserModuleService;
import org.openelisglobal.systemmodule.service.SystemModuleUrlService;
@@ -61,7 +61,7 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response,
}
protected boolean hasPermission(Errors errors, HttpServletRequest request) {
- if (SystemConfiguration.getInstance().getPermissionAgent().equals("ROLE")) {
+ if (ConfigurationProperties.getInstance().getPropertyValue("permissions.agent").equalsIgnoreCase("ROLE")) {
return hasPermissionForUrl(request, USE_PARAMETERS) || userModuleService.isUserAdmin(request);
} else {
return userModuleService.isVerifyUserModule(request) || userModuleService.isUserAdmin(request);
diff --git a/src/main/java/org/openelisglobal/internationalization/GlobalLocaleResolver.java b/src/main/java/org/openelisglobal/internationalization/GlobalLocaleResolver.java
index 9546986c88..a32014a50c 100644
--- a/src/main/java/org/openelisglobal/internationalization/GlobalLocaleResolver.java
+++ b/src/main/java/org/openelisglobal/internationalization/GlobalLocaleResolver.java
@@ -1,24 +1,39 @@
package org.openelisglobal.internationalization;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.openelisglobal.common.util.ConfigurationProperties;
+import org.apache.commons.validator.GenericValidator;
+import org.openelisglobal.common.util.ConfigurationListener;
import org.openelisglobal.common.util.ConfigurationProperties.Property;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.DefaultConfigurationProperties;
+import org.openelisglobal.common.util.LocaleChangeListener;
+import org.openelisglobal.spring.util.SpringContext;
import org.springframework.context.i18n.LocaleContext;
+import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.i18n.AbstractLocaleContextResolver;
-public class GlobalLocaleResolver extends AbstractLocaleContextResolver {
+public class GlobalLocaleResolver extends AbstractLocaleContextResolver implements ConfigurationListener {
- private Locale defaultLocale = Locale
- .forLanguageTag(ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE));
+ private Locale defaultLocale;
private Locale currentLocale;
private TimeZone timeZone;
+ private List localChangeListeners = new ArrayList<>();
+
+ public GlobalLocaleResolver() {
+ defaultLocale = Locale.US;
+ }
+
+ public void addLocalChangeListener(LocaleChangeListener listener) {
+ localChangeListeners.add(listener);
+ }
+
@Override
public Locale resolveLocale(HttpServletRequest request) {
if (currentLocale == null) {
@@ -31,14 +46,18 @@ public Locale resolveLocale(HttpServletRequest request) {
public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {
if (!locale.equals(currentLocale)) {
currentLocale = locale;
- SystemConfiguration.getInstance().setDefaultLocale(locale.getLanguage());
}
currentLocale = locale;
}
@Override
public void setDefaultLocale(Locale locale) {
- defaultLocale = locale;
+ if (!defaultLocale.equals(locale)) {
+ this.defaultLocale = locale;
+ for (LocaleChangeListener listener : localChangeListeners) {
+ listener.localeChanged(locale.toLanguageTag());
+ }
+ }
}
@Override
@@ -93,4 +112,14 @@ public Locale determineDefaultLocale() {
protected TimeZone determineDefaultTimeZone(HttpServletRequest request) {
return getDefaultTimeZone();
}
+
+ @Override
+ public void refreshConfiguration() {
+ String localeTag = SpringContext.getBean(DefaultConfigurationProperties.class)
+ .getPropertyValue(Property.DEFAULT_LANG_LOCALE);
+ System.out.println("LOCALE IS: " + localeTag);
+ Locale locale = GenericValidator.isBlankOrNull(localeTag) ? Locale.US : Locale.forLanguageTag(localeTag);
+ setDefaultLocale(locale);
+ LocaleContextHolder.setDefaultLocale(locale);
+ }
}
diff --git a/src/main/java/org/openelisglobal/login/controller/LoginPageController.java b/src/main/java/org/openelisglobal/login/controller/LoginPageController.java
index 1cdc396d19..804b52c271 100644
--- a/src/main/java/org/openelisglobal/login/controller/LoginPageController.java
+++ b/src/main/java/org/openelisglobal/login/controller/LoginPageController.java
@@ -2,6 +2,7 @@
import java.security.Principal;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -31,8 +32,14 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ResolvableType;
import org.springframework.http.MediaType;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
+import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
+import org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal;
import org.springframework.security.web.csrf.CsrfToken;
import org.springframework.stereotype.Controller;
import org.springframework.validation.Errors;
@@ -132,7 +139,9 @@ public UserSession getSesssionDetails(HttpServletRequest request, CsrfToken toke
session.setLoginName(user.getLoginName());
session.setFirstName(user.getFirstName());
session.setLastName(user.getLastName());
- session.setCSRF(token.getToken());
+ if (token != null) {
+ session.setCSRF(token.getToken());
+ }
UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
if (usd.getLoginLabUnit() != 0) {
TestSection testSection = testSectionService.getTestSectionById(String.valueOf(usd.getLoginLabUnit()));
@@ -140,15 +149,49 @@ public UserSession getSesssionDetails(HttpServletRequest request, CsrfToken toke
session.setLoginLabUnit(testSection.getLocalizedName());
}
}
- setLabunitRolesForExistingUser(session);
- Set roles = new HashSet<>();
- for (String roleId : userRoleService.getRoleIdsForUser(user.getId())) {
- roles.add(roleService.getRoleById(roleId).getName().trim());
+ setLabunitRolesForExistingUser(request, session);
+ }
+ return session;
+ }
+
+ private void setLabunitRolesForExistingUser(HttpServletRequest request, UserSession session) {
+ Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+
+ if (authentication != null) {
+ Object principal = authentication.getPrincipal();
+ if (principal instanceof UserDetails) {
+ setLabunitRolesForExistingUserFromDB(session);
+ Set roles = new HashSet<>();
+ for (String roleId : userRoleService.getRoleIdsForUser(session.getUserId())) {
+ roles.add(roleService.getRoleById(roleId).getName().trim());
+ }
+ session.setRoles(roles);
+ } else if (principal instanceof DefaultSaml2AuthenticatedPrincipal) {
+ setLabunitRolesForExistingUserFromGrantedAuthorities(session, authentication);
+ } else if (principal instanceof DefaultOAuth2User) {
+ setLabunitRolesForExistingUserFromGrantedAuthorities(session, authentication);
}
- session.setRoles(roles);
+ }
+ }
+ private void setLabunitRolesForExistingUserFromGrantedAuthorities(UserSession session,
+ Authentication authentication) {
+ Collection extends GrantedAuthority> authorities = authentication.getAuthorities();
+ Map> userLabRolesMap = new HashMap<>();
+ Set roles = new HashSet<>();
+ for (GrantedAuthority authority : authorities) {
+ String[] authorityExplode = authority.getAuthority().split("-");
+ if (authorityExplode.length == 2) {
+ roles.add(authorityExplode[1]);
+ } else if (authorityExplode.length == 3) {
+ List userLabRoles = userLabRolesMap.getOrDefault(authorityExplode[2], new ArrayList<>());
+ userLabRoles.add(authorityExplode[1]);
+ roles.add(authorityExplode[1]);
+ userLabRolesMap.put(authorityExplode[2], userLabRoles);
+ }
}
- return session;
+ session.setRoles(roles);
+ session.setUserLabRolesMap(userLabRolesMap);
}
@PostMapping(value = "/rest/setUserLoginLabUnit/{labUnitId}", produces = MediaType.APPLICATION_JSON_VALUE)
@@ -166,7 +209,7 @@ public void setUserLoginLabUnit(@PathVariable String labUnitId) {
}
}
- private void setLabunitRolesForExistingUser(UserSession session) {
+ private void setLabunitRolesForExistingUserFromDB(UserSession session) {
UserLabUnitRoles roles = userService.getUserLabUnitRoles(session.getUserId());
if (roles != null) {
Set roleMaps = roles.getLabUnitRoleMap();
diff --git a/src/main/java/org/openelisglobal/login/daoimpl/UserModuleServiceImpl.java b/src/main/java/org/openelisglobal/login/daoimpl/UserModuleServiceImpl.java
index 159f8202e9..fafc1812ad 100644
--- a/src/main/java/org/openelisglobal/login/daoimpl/UserModuleServiceImpl.java
+++ b/src/main/java/org/openelisglobal/login/daoimpl/UserModuleServiceImpl.java
@@ -31,9 +31,11 @@
import org.openelisglobal.systemusermodule.valueholder.SystemUserModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
import org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal;
+import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -159,7 +161,16 @@ private LoginUser getUserLogin(HttpServletRequest request) throws LIMSRuntimeExc
// UserSessionData usd = (UserSessionData)
// request.getSession().getAttribute(USER_SESSION_DATA);
// login = loginService.getUserProfile(usd.getLoginName());
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ // Authentication authentication2 =
+ // SecurityContextHolder.getContext().getAuthentication();
+ // TODO workaround for Security Context authentication is null
+ Object sc = request.getSession()
+ .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
+ if (!(sc instanceof SecurityContext)) {
+ LogEvent.logWarn(this.getClass().getSimpleName(), "getUserLogin",
+ "security context is not of type SecurityContext");
+ }
+ Authentication authentication = ((SecurityContext) sc).getAuthentication();
if (authentication != null) {
Object principal = authentication.getPrincipal();
if (principal instanceof UserDetails) {
@@ -168,6 +179,9 @@ private LoginUser getUserLogin(HttpServletRequest request) throws LIMSRuntimeExc
} else if (principal instanceof DefaultSaml2AuthenticatedPrincipal) {
DefaultSaml2AuthenticatedPrincipal samlUser = (DefaultSaml2AuthenticatedPrincipal) principal;
login = loginService.getUserProfile(samlUser.getName());
+ } else if (principal instanceof DefaultOAuth2User) {
+ DefaultOAuth2User oauthUser = (DefaultOAuth2User) principal;
+ login = loginService.getUserProfile(oauthUser.getName());
}
}
} catch (LIMSRuntimeException e) {
diff --git a/src/main/java/org/openelisglobal/login/service/LoginUserServiceImpl.java b/src/main/java/org/openelisglobal/login/service/LoginUserServiceImpl.java
index 40cc5aa886..b26eb33927 100644
--- a/src/main/java/org/openelisglobal/login/service/LoginUserServiceImpl.java
+++ b/src/main/java/org/openelisglobal/login/service/LoginUserServiceImpl.java
@@ -11,7 +11,7 @@
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
import org.openelisglobal.common.service.AuditableBaseObjectServiceImpl;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.login.dao.LoginUserDAO;
import org.openelisglobal.login.valueholder.LoginUser;
import org.openelisglobal.security.PasswordUtil;
@@ -103,7 +103,7 @@ public void hashPassword(LoginUser login, String newPassword) {
login.setPassword(PasswordUtil.hashPassword(newPassword));
Calendar passwordExpiredDate = Calendar.getInstance();
passwordExpiredDate.add(Calendar.MONTH,
- Integer.parseInt(SystemConfiguration.getInstance().getLoginUserChangePasswordExpiredMonth()));
+ Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("login.user.expired.month")));
login.setPasswordExpiredDate(new Date(passwordExpiredDate.getTimeInMillis()));
login.setPasswordExpiredDayNo(baseObjectDAO.getPasswordExpiredDayNo(login));
}
diff --git a/src/main/java/org/openelisglobal/login/valueholder/LoginUser.java b/src/main/java/org/openelisglobal/login/valueholder/LoginUser.java
index 18fa609511..fc531e0439 100644
--- a/src/main/java/org/openelisglobal/login/valueholder/LoginUser.java
+++ b/src/main/java/org/openelisglobal/login/valueholder/LoginUser.java
@@ -24,8 +24,9 @@
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
+import org.openelisglobal.common.util.ConfigurationProperties;
+import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.DateUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.valueholder.BaseObject;
import org.openelisglobal.validation.annotations.ValidName;
import org.openelisglobal.validation.constraintvalidator.NameValidator.NameType;
@@ -169,7 +170,7 @@ public void setPasswordExpiredDate(Date passwordExpiredDT) {
public void setPasswordExpiredDateForDisplay(String passwordExpiredDTForDisplay) {
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
this.passwordExpiredDT = DateUtil.convertStringDateToSqlDate(passwordExpiredDTForDisplay, locale);
}
diff --git a/src/main/java/org/openelisglobal/menu/service/AdminMenuItemServiceImpl.java b/src/main/java/org/openelisglobal/menu/service/AdminMenuItemServiceImpl.java
index 78257efc5e..6f3ea3e895 100644
--- a/src/main/java/org/openelisglobal/menu/service/AdminMenuItemServiceImpl.java
+++ b/src/main/java/org/openelisglobal/menu/service/AdminMenuItemServiceImpl.java
@@ -9,12 +9,13 @@
import org.openelisglobal.common.formfields.AdminFormFields.Field;
import org.openelisglobal.common.util.ConfigurationListener;
import org.openelisglobal.common.util.ConfigurationProperties;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.internationalization.MessageUtil;
import org.openelisglobal.menu.valueholder.AdminMenuItem;
+import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Service;
@Service
+@DependsOn({ "springContext", "defaultConfigurationProperties" })
public class AdminMenuItemServiceImpl implements AdminMenuItemService, ConfigurationListener {
List adminMenuItems;
@@ -22,7 +23,7 @@ public class AdminMenuItemServiceImpl implements AdminMenuItemService, Configura
@PostConstruct
public synchronized void createActiveList() {
adminMenuItems = new ArrayList<>();
- String permissionBase = SystemConfiguration.getInstance().getPermissionAgent();
+ String permissionBase = ConfigurationProperties.getInstance().getPropertyValue("permissions.agent");
AdminFormFields adminFields = AdminFormFields.getInstance();
AdminMenuItem curItem;
@@ -170,7 +171,7 @@ public synchronized void createActiveList() {
curItem.setMessageKey("plugin.menu.list.plugins");
adminMenuItems.add(curItem);
- if (permissionBase.equals("ROLE")) {
+ if (permissionBase.equalsIgnoreCase("ROLE")) {
curItem = new AdminMenuItem();
curItem.setPath("/UnifiedSystemUserMenu");
curItem.setMessageKey("unifiedSystemUser.browser.title");
diff --git a/src/main/java/org/openelisglobal/method/valueholder/Method.java b/src/main/java/org/openelisglobal/method/valueholder/Method.java
index d33d9cd213..b79bb36807 100644
--- a/src/main/java/org/openelisglobal/method/valueholder/Method.java
+++ b/src/main/java/org/openelisglobal/method/valueholder/Method.java
@@ -14,8 +14,9 @@
package org.openelisglobal.method.valueholder;
import java.sql.Date;
+import org.openelisglobal.common.util.ConfigurationProperties;
+import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.DateUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.valueholder.EnumValueItemImpl;
import org.openelisglobal.common.valueholder.ValueHolder;
import org.openelisglobal.common.valueholder.ValueHolderInterface;
@@ -109,7 +110,7 @@ public String getIsActive() {
public void setActiveBeginDateForDisplay(String activeBeginDateForDisplay) {
this.activeBeginDateForDisplay = activeBeginDateForDisplay;
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
this.activeBeginDate = DateUtil.convertStringDateToSqlDate(this.activeBeginDateForDisplay, locale);
}
@@ -120,7 +121,7 @@ public String getActiveBeginDateForDisplay() {
public void setActiveEndDateForDisplay(String activeEndDateForDisplay) {
this.activeEndDateForDisplay = activeEndDateForDisplay;
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
this.activeEndDate = DateUtil.convertStringDateToSqlDate(activeEndDateForDisplay, locale);
}
diff --git a/src/main/java/org/openelisglobal/organization/controller/OrganizationMenuController.java b/src/main/java/org/openelisglobal/organization/controller/OrganizationMenuController.java
index 9155511b94..58d5e0a7f8 100644
--- a/src/main/java/org/openelisglobal/organization/controller/OrganizationMenuController.java
+++ b/src/main/java/org/openelisglobal/organization/controller/OrganizationMenuController.java
@@ -11,7 +11,7 @@
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.form.AdminOptionMenuForm;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.validator.BaseErrors;
import org.openelisglobal.dataexchange.fhir.exception.FhirTransformationException;
import org.openelisglobal.organization.form.OrganizationMenuForm;
@@ -106,8 +106,10 @@ protected List createMenuList(AdminOptionMenuForm fo
request.setAttribute(MENU_FROM_RECORD, String.valueOf(startingRecNo));
int numOfRecs = 0;
if (organizations != null) {
- if (organizations.size() > SystemConfiguration.getInstance().getDefaultPageSize()) {
- numOfRecs = SystemConfiguration.getInstance().getDefaultPageSize();
+ if (organizations.size() > Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))) {
+ numOfRecs = Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
} else {
numOfRecs = organizations.size();
}
@@ -138,7 +140,7 @@ protected String getDeactivateDisabled() {
@Override
protected int getPageSize() {
- return SystemConfiguration.getInstance().getDefaultPageSize();
+ return Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
}
// gnr: Deactivate not Delete
diff --git a/src/main/java/org/openelisglobal/organization/controller/rest/OrganizationMenuRestController.java b/src/main/java/org/openelisglobal/organization/controller/rest/OrganizationMenuRestController.java
index 6d63834da1..a361f40a76 100644
--- a/src/main/java/org/openelisglobal/organization/controller/rest/OrganizationMenuRestController.java
+++ b/src/main/java/org/openelisglobal/organization/controller/rest/OrganizationMenuRestController.java
@@ -9,7 +9,7 @@
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.form.AdminOptionMenuForm;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.validator.BaseErrors;
import org.openelisglobal.dataexchange.fhir.exception.FhirTransformationException;
import org.openelisglobal.organization.form.OrganizationMenuForm;
@@ -115,8 +115,10 @@ protected List createMenuList(AdminOptionMenuForm fo
request.setAttribute(MENU_FROM_RECORD, String.valueOf(startingRecNo));
int numOfRecs = 0;
if (organizations != null) {
- if (organizations.size() > SystemConfiguration.getInstance().getDefaultPageSize()) {
- numOfRecs = SystemConfiguration.getInstance().getDefaultPageSize();
+ if (organizations.size() > Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))) {
+ numOfRecs = Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
} else {
numOfRecs = organizations.size();
}
@@ -151,7 +153,7 @@ protected String getDeactivateDisabled() {
@Override
protected int getPageSize() {
- return SystemConfiguration.getInstance().getDefaultPageSize();
+ return Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
}
// gnr: Deactivate not Delete
diff --git a/src/main/java/org/openelisglobal/organization/daoimpl/OrganizationDAOImpl.java b/src/main/java/org/openelisglobal/organization/daoimpl/OrganizationDAOImpl.java
index 720bd390ae..8c8122a077 100644
--- a/src/main/java/org/openelisglobal/organization/daoimpl/OrganizationDAOImpl.java
+++ b/src/main/java/org/openelisglobal/organization/daoimpl/OrganizationDAOImpl.java
@@ -26,8 +26,8 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.organization.dao.OrganizationDAO;
import org.openelisglobal.organization.valueholder.Organization;
import org.springframework.stereotype.Component;
@@ -85,7 +85,9 @@ public List getPageOfOrganizations(int startingRecNo) throws LIMSR
List list;
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
// bugzilla 1399
String sql = "from Organization o order by o.organizationName";
@@ -114,7 +116,9 @@ public List getPagesOfSearchedOrganizations(int startingRecNo, Str
String sql;
try {
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
int wCdPosition = searchString.indexOf(wildCard);
if (wCdPosition == -1) // no wild card looking for exact match
diff --git a/src/main/java/org/openelisglobal/panel/daoimpl/PanelDAOImpl.java b/src/main/java/org/openelisglobal/panel/daoimpl/PanelDAOImpl.java
index c0a813ed51..1851c8ffdc 100644
--- a/src/main/java/org/openelisglobal/panel/daoimpl/PanelDAOImpl.java
+++ b/src/main/java/org/openelisglobal/panel/daoimpl/PanelDAOImpl.java
@@ -25,8 +25,8 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.panel.dao.PanelDAO;
import org.openelisglobal.panel.valueholder.Panel;
import org.springframework.stereotype.Component;
@@ -113,7 +113,9 @@ public List getPageOfPanels(int startingRecNo) throws LIMSRuntimeExceptio
List list;
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
// bugzilla 1399
String sql = "from Panel p order by p.panelName";
diff --git a/src/main/java/org/openelisglobal/panelitem/daoimpl/PanelItemDAOImpl.java b/src/main/java/org/openelisglobal/panelitem/daoimpl/PanelItemDAOImpl.java
index 52a780a3cd..23463d843c 100644
--- a/src/main/java/org/openelisglobal/panelitem/daoimpl/PanelItemDAOImpl.java
+++ b/src/main/java/org/openelisglobal/panelitem/daoimpl/PanelItemDAOImpl.java
@@ -22,8 +22,8 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.panelitem.dao.PanelItemDAO;
import org.openelisglobal.panelitem.valueholder.PanelItem;
import org.springframework.stereotype.Component;
@@ -78,7 +78,9 @@ public List getPageOfPanelItems(int startingRecNo) throws LIMSRuntime
List list;
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from PanelItem p order by p.panel.panelName, p.testName";
Query query = entityManager.unwrap(Session.class).createQuery(sql, PanelItem.class);
diff --git a/src/main/java/org/openelisglobal/patient/daoimpl/PatientDAOImpl.java b/src/main/java/org/openelisglobal/patient/daoimpl/PatientDAOImpl.java
index 8975620d1a..37430e664c 100644
--- a/src/main/java/org/openelisglobal/patient/daoimpl/PatientDAOImpl.java
+++ b/src/main/java/org/openelisglobal/patient/daoimpl/PatientDAOImpl.java
@@ -25,8 +25,8 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.DateUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.patient.dao.PatientDAO;
import org.openelisglobal.patient.valueholder.Patient;
import org.openelisglobal.person.valueholder.Person;
@@ -123,7 +123,9 @@ public List getPageOfPatients(int startingRecNo) throws LIMSRuntimeExce
List patients;
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from Patient t order by t.id";
Query query = entityManager.unwrap(Session.class).createQuery(sql, Patient.class);
diff --git a/src/main/java/org/openelisglobal/patient/saving/Accessioner.java b/src/main/java/org/openelisglobal/patient/saving/Accessioner.java
index 8445772742..84fd9e70b8 100644
--- a/src/main/java/org/openelisglobal/patient/saving/Accessioner.java
+++ b/src/main/java/org/openelisglobal/patient/saving/Accessioner.java
@@ -55,9 +55,9 @@
import org.openelisglobal.common.services.StatusService.RecordStatus;
import org.openelisglobal.common.services.StatusService.SampleStatus;
import org.openelisglobal.common.services.StatusSet;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.DateUtil;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.dataexchange.fhir.service.FhirTransformService;
import org.openelisglobal.note.service.NoteService;
import org.openelisglobal.note.service.NoteServiceImpl;
@@ -716,7 +716,7 @@ protected void populateSample(Timestamp receivedDateForDisplay, Timestamp collec
sample.setEnteredDateForDisplay(todayAsText);
sample.setEnteredDate(today);
}
- sample.setDomain(SystemConfiguration.getInstance().getHumanDomain());
+ sample.setDomain(ConfigurationProperties.getInstance().getPropertyValue("domain.human"));
}
protected void populateSampleProject() {
@@ -924,7 +924,7 @@ protected void persistSampleItemsAndAnalysis() {
Map itemsByType = findExistingSampleTypeItems();
int nextSortOrder = calcLastSortOrder(itemsByType) + 1;
- String analysisRevision = SystemConfiguration.getInstance().getAnalysisDefaultRevision();
+ String analysisRevision = ConfigurationProperties.getInstance().getPropertyValue("analysis.default.revision");
boolean newAnalysis = false;
for (SampleItemAnalysisCollection sampleTestPair : sampleItemsAnalysis) {
diff --git a/src/main/java/org/openelisglobal/patienttype/daoimpl/PatientTypeDAOImpl.java b/src/main/java/org/openelisglobal/patienttype/daoimpl/PatientTypeDAOImpl.java
index 1378d01a8f..ea0c5017fa 100644
--- a/src/main/java/org/openelisglobal/patienttype/daoimpl/PatientTypeDAOImpl.java
+++ b/src/main/java/org/openelisglobal/patienttype/daoimpl/PatientTypeDAOImpl.java
@@ -19,8 +19,8 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.patienttype.dao.PatientTypeDAO;
import org.openelisglobal.patienttype.valueholder.PatientType;
import org.springframework.stereotype.Component;
@@ -184,7 +184,9 @@ public List getPageOfPatientType(int startingRecNo) throws LIMSRunt
List list = new Vector<>();
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from PatientType l order by l.type";
org.hibernate.query.Query query = entityManager.unwrap(Session.class).createQuery(sql);
diff --git a/src/main/java/org/openelisglobal/person/daoimpl/PersonDAOImpl.java b/src/main/java/org/openelisglobal/person/daoimpl/PersonDAOImpl.java
index 110ad82c98..614ec3174c 100644
--- a/src/main/java/org/openelisglobal/person/daoimpl/PersonDAOImpl.java
+++ b/src/main/java/org/openelisglobal/person/daoimpl/PersonDAOImpl.java
@@ -25,7 +25,7 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.person.dao.PersonDAO;
import org.openelisglobal.person.valueholder.Person;
import org.springframework.stereotype.Component;
@@ -83,7 +83,9 @@ public List getPageOfPersons(int startingRecNo) throws LIMSRuntimeExcept
List list = new Vector<>();
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from Person t order by t.id";
Query query = entityManager.unwrap(Session.class).createQuery(sql, Person.class);
diff --git a/src/main/java/org/openelisglobal/project/daoimpl/ProjectDAOImpl.java b/src/main/java/org/openelisglobal/project/daoimpl/ProjectDAOImpl.java
index c84b8df0f6..5c6e013eb4 100644
--- a/src/main/java/org/openelisglobal/project/daoimpl/ProjectDAOImpl.java
+++ b/src/main/java/org/openelisglobal/project/daoimpl/ProjectDAOImpl.java
@@ -24,9 +24,9 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.DateUtil;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.project.dao.ProjectDAO;
import org.openelisglobal.project.valueholder.Project;
import org.springframework.stereotype.Component;
@@ -89,7 +89,9 @@ public List getPageOfProjects(int startingRecNo) throws LIMSRuntimeExce
List list;
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
// bugzilla 1399
// bugzilla 2438 order by local abbreviation
diff --git a/src/main/java/org/openelisglobal/project/valueholder/Project.java b/src/main/java/org/openelisglobal/project/valueholder/Project.java
index b8ffae16c6..4a4963e815 100644
--- a/src/main/java/org/openelisglobal/project/valueholder/Project.java
+++ b/src/main/java/org/openelisglobal/project/valueholder/Project.java
@@ -17,8 +17,9 @@
import java.sql.Date;
import java.util.Set;
+import org.openelisglobal.common.util.ConfigurationProperties;
+import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.DateUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.valueholder.BaseObject;
import org.openelisglobal.common.valueholder.ValueHolder;
import org.openelisglobal.common.valueholder.ValueHolderInterface;
@@ -217,7 +218,7 @@ public String getOpOpId() {
public void setStartedDateForDisplay(String startedDateForDisplay) {
this.startedDateForDisplay = startedDateForDisplay;
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
this.startedDate = DateUtil.convertStringDateToSqlDate(this.startedDateForDisplay, locale);
}
@@ -228,7 +229,7 @@ public String getStartedDateForDisplay() {
public void setCompletedDateForDisplay(String completedDateForDisplay) {
this.completedDateForDisplay = completedDateForDisplay;
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
this.completedDate = DateUtil.convertStringDateToSqlDate(completedDateForDisplay, locale);
}
diff --git a/src/main/java/org/openelisglobal/provider/controller/ProviderMenuController.java b/src/main/java/org/openelisglobal/provider/controller/ProviderMenuController.java
index 51c084b75d..c9efdd6400 100644
--- a/src/main/java/org/openelisglobal/provider/controller/ProviderMenuController.java
+++ b/src/main/java/org/openelisglobal/provider/controller/ProviderMenuController.java
@@ -11,7 +11,7 @@
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.form.AdminOptionMenuForm;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.validator.BaseErrors;
import org.openelisglobal.provider.form.ProviderMenuForm;
import org.openelisglobal.provider.service.ProviderService;
@@ -91,8 +91,10 @@ protected List createMenuList(AdminOptionMenuForm form, Http
request.setAttribute(MENU_FROM_RECORD, String.valueOf(startingRecNo));
int numOfRecs = 0;
if (providers != null) {
- if (providers.size() > SystemConfiguration.getInstance().getDefaultPageSize()) {
- numOfRecs = SystemConfiguration.getInstance().getDefaultPageSize();
+ if (providers.size() > Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))) {
+ numOfRecs = Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
} else {
numOfRecs = providers.size();
}
@@ -133,7 +135,7 @@ protected String getEditDisabled() {
@Override
protected int getPageSize() {
- return SystemConfiguration.getInstance().getDefaultPageSize();
+ return Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
}
// gnr: Deactivate not Delete
diff --git a/src/main/java/org/openelisglobal/provider/controller/rest/ProviderMenuRestController.java b/src/main/java/org/openelisglobal/provider/controller/rest/ProviderMenuRestController.java
index 9a83a3e6cc..d202e11465 100644
--- a/src/main/java/org/openelisglobal/provider/controller/rest/ProviderMenuRestController.java
+++ b/src/main/java/org/openelisglobal/provider/controller/rest/ProviderMenuRestController.java
@@ -10,7 +10,7 @@
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.form.AdminOptionMenuForm;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.provider.form.ProviderMenuForm;
import org.openelisglobal.provider.service.ProviderService;
import org.openelisglobal.provider.valueholder.Provider;
@@ -106,8 +106,10 @@ protected List createMenuList(AdminOptionMenuForm form, Http
request.setAttribute(MENU_FROM_RECORD, String.valueOf(startingRecNo));
int numOfRecs = 0;
if (providers != null) {
- if (providers.size() > SystemConfiguration.getInstance().getDefaultPageSize()) {
- numOfRecs = SystemConfiguration.getInstance().getDefaultPageSize();
+ if (providers.size() > Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))) {
+ numOfRecs = Integer
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
} else {
numOfRecs = providers.size();
}
@@ -151,7 +153,7 @@ protected String getEditDisabled() {
@Override
protected int getPageSize() {
- return SystemConfiguration.getInstance().getDefaultPageSize();
+ return Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
}
// gnr: Deactivate not Delete
diff --git a/src/main/java/org/openelisglobal/provider/daoimpl/ProviderDAOImpl.java b/src/main/java/org/openelisglobal/provider/daoimpl/ProviderDAOImpl.java
index 62bd6be497..68ad51b9f0 100644
--- a/src/main/java/org/openelisglobal/provider/daoimpl/ProviderDAOImpl.java
+++ b/src/main/java/org/openelisglobal/provider/daoimpl/ProviderDAOImpl.java
@@ -22,7 +22,7 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.person.valueholder.Person;
import org.openelisglobal.provider.dao.ProviderDAO;
import org.openelisglobal.provider.valueholder.Provider;
@@ -80,7 +80,9 @@ public List getPageOfProviders(int startingRecNo) throws LIMSRuntimeEx
List list = new Vector<>();
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from Provider p order by p.id";
Query query = entityManager.unwrap(Session.class).createQuery(sql, Provider.class);
@@ -157,7 +159,9 @@ public List getPagesOfSearchedProviders(int startingRecNo, String para
List list = new Vector<>();
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from Provider p where lower(p.person.firstName) like concat('%', lower(:searchValue),"
+ " '%') or lower(p.person.lastName) like concat('%', lower(:searchValue), '%') or"
diff --git a/src/main/java/org/openelisglobal/qaevent/controller/RejectionController.java b/src/main/java/org/openelisglobal/qaevent/controller/RejectionController.java
index 7acb5b2324..e568d035d4 100644
--- a/src/main/java/org/openelisglobal/qaevent/controller/RejectionController.java
+++ b/src/main/java/org/openelisglobal/qaevent/controller/RejectionController.java
@@ -20,7 +20,6 @@
import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.DateUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.organization.service.OrganizationService;
import org.openelisglobal.organization.valueholder.Organization;
import org.openelisglobal.project.service.ProjectService;
@@ -179,7 +178,7 @@ public ModelAndView showNonConformityUpdate(HttpServletRequest request,
DateUtil.convertStringDateToTruncatedTimestamp(form.getCollectionDateForDisplay()));
rejectedSample.setEnteredDate(DateUtil.getNowAsSqlDate());
rejectedSample.setPriority(OrderPriority.ROUTINE);
- rejectedSample.setDomain(SystemConfiguration.getInstance().getHumanDomain());
+ rejectedSample.setDomain(ConfigurationProperties.getInstance().getPropertyValue("domain.human"));
rejectedSample.setStatusId(SpringContext.getBean(IStatusService.class).getStatusID(OrderStatus.Entered));
rejectedSample.setReceivedTimestamp(
DateUtil.convertStringDateToTruncatedTimestamp(form.getReceptionDateForDisplay()));
diff --git a/src/main/java/org/openelisglobal/qaevent/daoimpl/QaEventDAOImpl.java b/src/main/java/org/openelisglobal/qaevent/daoimpl/QaEventDAOImpl.java
index 2b4a4580a6..6310b1267e 100644
--- a/src/main/java/org/openelisglobal/qaevent/daoimpl/QaEventDAOImpl.java
+++ b/src/main/java/org/openelisglobal/qaevent/daoimpl/QaEventDAOImpl.java
@@ -23,8 +23,8 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.qaevent.dao.QaEventDAO;
import org.openelisglobal.qaevent.valueholder.QaEvent;
import org.springframework.stereotype.Component;
@@ -81,7 +81,9 @@ public List getPageOfQaEvents(int startingRecNo) throws LIMSRuntimeExce
List list = new Vector<>();
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from QaEvent qe order by qe.qaEventName";
Query query = entityManager.unwrap(Session.class).createQuery(sql, QaEvent.class);
diff --git a/src/main/java/org/openelisglobal/referencetables/daoimpl/ReferenceTablesDAOImpl.java b/src/main/java/org/openelisglobal/referencetables/daoimpl/ReferenceTablesDAOImpl.java
index 6630c07b47..6d590a87c2 100644
--- a/src/main/java/org/openelisglobal/referencetables/daoimpl/ReferenceTablesDAOImpl.java
+++ b/src/main/java/org/openelisglobal/referencetables/daoimpl/ReferenceTablesDAOImpl.java
@@ -24,8 +24,8 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.referencetables.dao.ReferenceTablesDAO;
import org.openelisglobal.referencetables.valueholder.ReferenceTables;
import org.springframework.stereotype.Component;
@@ -83,7 +83,9 @@ public List getPageOfReferenceTables(int startingRecNo) throws
List list = new Vector<>();
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from ReferenceTables r order by r.tableName";
Query query = entityManager.unwrap(Session.class).createQuery(sql, ReferenceTables.class);
diff --git a/src/main/java/org/openelisglobal/renamemethod/valueholder/RenameMethod.java b/src/main/java/org/openelisglobal/renamemethod/valueholder/RenameMethod.java
index c54c30f714..8ab716c996 100644
--- a/src/main/java/org/openelisglobal/renamemethod/valueholder/RenameMethod.java
+++ b/src/main/java/org/openelisglobal/renamemethod/valueholder/RenameMethod.java
@@ -14,8 +14,9 @@
package org.openelisglobal.renamemethod.valueholder;
import java.sql.Date;
+import org.openelisglobal.common.util.ConfigurationProperties;
+import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.DateUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.valueholder.EnumValueItemImpl;
import org.openelisglobal.common.valueholder.ValueHolder;
import org.openelisglobal.common.valueholder.ValueHolderInterface;
@@ -109,7 +110,7 @@ public String getIsActive() {
public void setActiveBeginDateForDisplay(String activeBeginDateForDisplay) {
this.activeBeginDateForDisplay = activeBeginDateForDisplay;
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
this.activeBeginDate = DateUtil.convertStringDateToSqlDate(this.activeBeginDateForDisplay, locale);
}
@@ -120,7 +121,7 @@ public String getActiveBeginDateForDisplay() {
public void setActiveEndDateForDisplay(String activeEndDateForDisplay) {
this.activeEndDateForDisplay = activeEndDateForDisplay;
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
this.activeEndDate = DateUtil.convertStringDateToSqlDate(activeEndDateForDisplay, locale);
}
diff --git a/src/main/java/org/openelisglobal/renametestsection/daoimpl/RenameTestSectionDAOImpl.java b/src/main/java/org/openelisglobal/renametestsection/daoimpl/RenameTestSectionDAOImpl.java
index c5de3492d1..4fa9a00366 100644
--- a/src/main/java/org/openelisglobal/renametestsection/daoimpl/RenameTestSectionDAOImpl.java
+++ b/src/main/java/org/openelisglobal/renametestsection/daoimpl/RenameTestSectionDAOImpl.java
@@ -23,8 +23,8 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.renametestsection.dao.RenameTestSectionDAO;
import org.openelisglobal.renametestsection.valueholder.RenameTestSection;
import org.springframework.stereotype.Component;
@@ -84,7 +84,9 @@ public List getPageOfTestSections(int startingRecNo) throws L
List list = new Vector<>();
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
// bugzilla 1399
String sql = "from TestSection t order by t.testSectionName";
diff --git a/src/main/java/org/openelisglobal/reports/service/WHONetReportServiceImpl.java b/src/main/java/org/openelisglobal/reports/service/WHONetReportServiceImpl.java
index d0736331c6..de64dab36a 100644
--- a/src/main/java/org/openelisglobal/reports/service/WHONetReportServiceImpl.java
+++ b/src/main/java/org/openelisglobal/reports/service/WHONetReportServiceImpl.java
@@ -72,11 +72,7 @@ public List getAntimicrobialEntries(Date lowDate, Date highDate) {
List analysises = analysisService.getAllAnalysisByTestsAndStatusAndCompletedDateRange(testIds,
ANALYSIS_STATUS_IDS, SAMPLE_STATUS_IDS, lowDate, highDate);
- System.out.println(
- "analysises" + String.join(", ", analysises.stream().map(e -> e.getId()).collect(Collectors.toList())));
analysises.stream().forEach(e -> sampleItems.putIfAbsent(e.getSampleItem().getId(), e.getSampleItem()));
- System.out.println("sampleItems"
- + String.join(", ", analysises.stream().map(e -> e.getId()).collect(Collectors.toList())));
return new ArrayList(sampleItems.values());
}
diff --git a/src/main/java/org/openelisglobal/result/controller/AccessionResultsController.java b/src/main/java/org/openelisglobal/result/controller/AccessionResultsController.java
index e04fa305a6..28a2e7774e 100644
--- a/src/main/java/org/openelisglobal/result/controller/AccessionResultsController.java
+++ b/src/main/java/org/openelisglobal/result/controller/AccessionResultsController.java
@@ -63,7 +63,6 @@ public AccessionResultsController(RoleService roleService) {
public ModelAndView showAccessionResults(HttpServletRequest request)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
AccessionResultsForm form = new AccessionResultsForm();
- System.out.println("AccessionResultsController:");
request.getSession().setAttribute(SAVE_DISABLED, TRUE);
form.setReferralReasons(DisplayListService.getInstance().getList(DisplayListService.ListType.REFERRAL_REASONS));
form.setRejectReasons(DisplayListService.getInstance()
diff --git a/src/main/java/org/openelisglobal/result/controller/PatientResultsController.java b/src/main/java/org/openelisglobal/result/controller/PatientResultsController.java
index 57c5c1a24f..73483835f2 100644
--- a/src/main/java/org/openelisglobal/result/controller/PatientResultsController.java
+++ b/src/main/java/org/openelisglobal/result/controller/PatientResultsController.java
@@ -51,9 +51,6 @@ public void initBinder(WebDataBinder binder) {
public ModelAndView showPatientResults(HttpServletRequest request)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
- System.out.println(
- "Get:PatientResultsController:showPatientResults:patientID:" + request.getParameter("patientID"));
-
PatientResultsForm form = new PatientResultsForm();
form.setReferralOrganizations(DisplayListService.getInstance().getList(ListType.REFERRAL_ORGANIZATIONS));
diff --git a/src/main/java/org/openelisglobal/result/controller/rest/ResultsRestController.java b/src/main/java/org/openelisglobal/result/controller/rest/ResultsRestController.java
index 36a9274f81..f4e794665b 100644
--- a/src/main/java/org/openelisglobal/result/controller/rest/ResultsRestController.java
+++ b/src/main/java/org/openelisglobal/result/controller/rest/ResultsRestController.java
@@ -1,7 +1,5 @@
package org.openelisglobal.result.controller.rest;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@@ -70,16 +68,7 @@ public ResultsRestController(RoleService roleService) {
@ResponseBody
public AccessionResultsForm getResults(@RequestParam String labNumber)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
- // System.out.println("Get Results:");
- // System.out.println("Get Results:" + request.toString());
-
- // return
- // DisplayListService.getInstance().getList(DisplayListService.ListType.ALL_TESTS);
- // HttpServletRequest request = null;
- System.out.println("ResultsRestController getTestResult:labNumber:" + labNumber);
String accessionNumber = labNumber;
- // String accessionNumber = "TESTA220000000000042";
- // String accessionNumber = "TESTA220000000000037";
AccessionResultsForm form = new AccessionResultsForm();
@@ -151,34 +140,6 @@ public AccessionResultsForm getResults(@RequestParam String labNumber)
paging.page(request, form, Integer.parseInt(newPage));
}
- System.out.println("ResultsRestController getTestResult:");
-
- List testResultItems = form.getTestResult();
- //// Timestamp now = new Timestamp(System.currentTimeMillis());
- //
- // testResultItems.forEach(item -> {
- ////
- // item.getResult().getAnalysis().getTestSection().getOrganization().setLastupdated(now);
- //// System.out.println(":" +
- // item.getResult().getAnalysis().getTestSection().getOrganization().getLastupdated());
- // System.out.println(":" + item.getTestName());
- // });
- //
- ObjectMapper mapper = new ObjectMapper();
- String jsonForm = "";
- try {
- jsonForm = mapper.writeValueAsString(form);
- } catch (JsonProcessingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- //
- // IdValuePair formsEntry = new IdValuePair("0", jsonForm);
- // List forms = new ArrayList<>();
- // forms.add(0, formsEntry);
-
- // System.out.println("ResultsRestController jsonForm:" + jsonForm);
-
return (form);
}
diff --git a/src/main/java/org/openelisglobal/result/daoimpl/ResultDAOImpl.java b/src/main/java/org/openelisglobal/result/daoimpl/ResultDAOImpl.java
index 7234fdb08c..7a798c6331 100644
--- a/src/main/java/org/openelisglobal/result/daoimpl/ResultDAOImpl.java
+++ b/src/main/java/org/openelisglobal/result/daoimpl/ResultDAOImpl.java
@@ -27,7 +27,7 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.result.dao.ResultDAO;
import org.openelisglobal.result.valueholder.Result;
import org.openelisglobal.sample.valueholder.Sample;
@@ -172,7 +172,9 @@ public List getPageOfResults(int startingRecNo) throws LIMSRuntimeExcept
List results;
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from Result r order by r.id";
Query query = entityManager.unwrap(Session.class).createQuery(sql, Result.class);
diff --git a/src/main/java/org/openelisglobal/resultlimits/daoimpl/ResultLimitDAOImpl.java b/src/main/java/org/openelisglobal/resultlimits/daoimpl/ResultLimitDAOImpl.java
index c171ea2384..fac773b617 100644
--- a/src/main/java/org/openelisglobal/resultlimits/daoimpl/ResultLimitDAOImpl.java
+++ b/src/main/java/org/openelisglobal/resultlimits/daoimpl/ResultLimitDAOImpl.java
@@ -25,7 +25,7 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.resultlimits.dao.ResultLimitDAO;
import org.openelisglobal.resultlimits.valueholder.ResultLimit;
import org.springframework.stereotype.Component;
@@ -77,7 +77,9 @@ public List getPageOfResultLimits(int startingRecNo) throws LIMSRun
List list;
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from ResultLimit t order by t.id";
Query query = entityManager.unwrap(Session.class).createQuery(sql, ResultLimit.class);
diff --git a/src/main/java/org/openelisglobal/resultreporting/controller/ResultReportingConfigurationController.java b/src/main/java/org/openelisglobal/resultreporting/controller/ResultReportingConfigurationController.java
index 25b8dad38b..8085579abc 100644
--- a/src/main/java/org/openelisglobal/resultreporting/controller/ResultReportingConfigurationController.java
+++ b/src/main/java/org/openelisglobal/resultreporting/controller/ResultReportingConfigurationController.java
@@ -105,7 +105,7 @@ public ModelAndView showUpdateResultReportingConfiguration(HttpServletRequest re
return findForward(FWD_FAIL_INSERT, form);
}
- ConfigurationProperties.forceReload();
+ ConfigurationProperties.loadDBValuesIntoConfiguration();
SpringContext.getBean(SchedulerConfig.class).reloadSchedules();
redirectAttributes.addFlashAttribute(FWD_SUCCESS, true);
diff --git a/src/main/java/org/openelisglobal/resultreporting/controller/rest/ResultReportingConfigurationRestController.java b/src/main/java/org/openelisglobal/resultreporting/controller/rest/ResultReportingConfigurationRestController.java
index 18b9cfa8dd..e9a1d685a0 100644
--- a/src/main/java/org/openelisglobal/resultreporting/controller/rest/ResultReportingConfigurationRestController.java
+++ b/src/main/java/org/openelisglobal/resultreporting/controller/rest/ResultReportingConfigurationRestController.java
@@ -108,7 +108,7 @@ public ResultReportingConfigurationForm showUpdateResultReportingConfiguration(H
return form;
}
- ConfigurationProperties.forceReload();
+ ConfigurationProperties.loadDBValuesIntoConfiguration();
SpringContext.getBean(SchedulerConfig.class).reloadSchedules();
// redirectAttributes.addFlashAttribute(FWD_SUCCESS, true);
diff --git a/src/main/java/org/openelisglobal/resultreporting/service/ResultReportingConfigurationServiceImpl.java b/src/main/java/org/openelisglobal/resultreporting/service/ResultReportingConfigurationServiceImpl.java
index 71a4a00c63..7426f0cd63 100644
--- a/src/main/java/org/openelisglobal/resultreporting/service/ResultReportingConfigurationServiceImpl.java
+++ b/src/main/java/org/openelisglobal/resultreporting/service/ResultReportingConfigurationServiceImpl.java
@@ -30,6 +30,6 @@ public void updateInformationAndSchedulers(List informationList
schedulerService.update(scheduler);
}
- ConfigurationProperties.forceReload();
+ ConfigurationProperties.loadDBValuesIntoConfiguration();
}
}
diff --git a/src/main/java/org/openelisglobal/resultvalidation/controller/AccessionValidationController.java b/src/main/java/org/openelisglobal/resultvalidation/controller/AccessionValidationController.java
index 73b6181683..c1218570ac 100644
--- a/src/main/java/org/openelisglobal/resultvalidation/controller/AccessionValidationController.java
+++ b/src/main/java/org/openelisglobal/resultvalidation/controller/AccessionValidationController.java
@@ -1,7 +1,5 @@
package org.openelisglobal.resultvalidation.controller;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.*;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -130,17 +128,6 @@ public ModelAndView showAccessionValidation(HttpServletRequest request, Accessio
request.setAttribute("analysisCount", count);
request.setAttribute("pageSize", count);
- ObjectMapper mapper = new ObjectMapper();
- String jsonForm = "";
- try {
- jsonForm = mapper.writeValueAsString(form);
- } catch (JsonProcessingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- System.out.println("AccessionValidationController:jsonForm:" + jsonForm);
-
return findForward(FWD_SUCCESS, form);
}
diff --git a/src/main/java/org/openelisglobal/resultvalidation/controller/rest/AccessionValidationRestController.java b/src/main/java/org/openelisglobal/resultvalidation/controller/rest/AccessionValidationRestController.java
index 0eeffdea2b..19093af9e3 100644
--- a/src/main/java/org/openelisglobal/resultvalidation/controller/rest/AccessionValidationRestController.java
+++ b/src/main/java/org/openelisglobal/resultvalidation/controller/rest/AccessionValidationRestController.java
@@ -262,7 +262,6 @@ public ResultValidationForm showAccessionValidationRangeSave(HttpServletRequest
.getAttribute(IActionConstants.RESULTS_SESSION_CACHE);
List checkResults = (List) checkPagedResults.get(0);
if (checkResults.size() == 0) {
- System.out.println("Operation failed");
LogEvent.logDebug(this.getClass().getSimpleName(), "ResultValidation()", "Attempted save of stale page.");
return form;
}
@@ -327,7 +326,6 @@ public ResultValidationForm showAccessionValidationRangeSave(HttpServletRequest
// if
// (ConfigurationProperties.getInstance().isPropertyValueEqual(Property.configurationName,
// "CI RetroCI"))
- System.out.println("Operation success");
// redirectAttributes.addFlashAttribute(FWD_SUCCESS, true);
if (isBlankOrNull(testSectionName)) {
// return findForward(forward, form);
diff --git a/src/main/java/org/openelisglobal/resultvalidation/service/ResultValidationServiceImpl.java b/src/main/java/org/openelisglobal/resultvalidation/service/ResultValidationServiceImpl.java
index 5f9d5db588..90ad55b6ef 100644
--- a/src/main/java/org/openelisglobal/resultvalidation/service/ResultValidationServiceImpl.java
+++ b/src/main/java/org/openelisglobal/resultvalidation/service/ResultValidationServiceImpl.java
@@ -116,10 +116,7 @@ private void checkIfSamplesFinished(List resultItemList, List sampleFinishedStatus = getSampleFinishedStatuses();
- // System.out.println("checkIfSamplesFinished:");
for (AnalysisItem analysisItem : resultItemList) {
- // System.out.println("checkIfSamplesFinished:" +
- // analysisItem.getAccessionNumber());
String analysisSampleId = sampleService.getSampleByAccessionNumber(analysisItem.getAccessionNumber())
.getId();
if (!analysisSampleId.equals(currentSampleId)) {
diff --git a/src/main/java/org/openelisglobal/role/daoimpl/RoleDAOImpl.java b/src/main/java/org/openelisglobal/role/daoimpl/RoleDAOImpl.java
index e1f9d86840..303ef86319 100644
--- a/src/main/java/org/openelisglobal/role/daoimpl/RoleDAOImpl.java
+++ b/src/main/java/org/openelisglobal/role/daoimpl/RoleDAOImpl.java
@@ -26,7 +26,7 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.role.dao.RoleDAO;
import org.openelisglobal.role.valueholder.Role;
import org.springframework.stereotype.Component;
@@ -92,7 +92,9 @@ public List getPageOfRoles(int startingRecNo) throws LIMSRuntimeException
List list = null;
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from Role r order by r.id";
Query query = entityManager.unwrap(Session.class).createQuery(sql, Role.class);
diff --git a/src/main/java/org/openelisglobal/sample/action/util/SamplePatientUpdateData.java b/src/main/java/org/openelisglobal/sample/action/util/SamplePatientUpdateData.java
index 21ad8ebf41..00e83b1cdf 100644
--- a/src/main/java/org/openelisglobal/sample/action/util/SamplePatientUpdateData.java
+++ b/src/main/java/org/openelisglobal/sample/action/util/SamplePatientUpdateData.java
@@ -35,7 +35,6 @@
import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.DateUtil;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.dataexchange.order.valueholder.ElectronicOrder;
import org.openelisglobal.dataexchange.service.order.ElectronicOrderService;
import org.openelisglobal.observationhistory.service.ObservationHistoryService;
@@ -322,7 +321,7 @@ public void createPopulatedSample(String receivedDate, SampleOrderItem sampleOrd
sample.setCollectionDateForDisplay(collectionDateFromReceiveDate);
}
- sample.setDomain(SystemConfiguration.getInstance().getHumanDomain());
+ sample.setDomain(ConfigurationProperties.getInstance().getPropertyValue("domain.human"));
sample.setStatusId(SpringContext.getBean(IStatusService.class).getStatusID(OrderStatus.Entered));
setElectronicOrderIfNeeded(sampleOrder);
diff --git a/src/main/java/org/openelisglobal/sample/daoimpl/DBSearchResultsDAOImpl.java b/src/main/java/org/openelisglobal/sample/daoimpl/DBSearchResultsDAOImpl.java
index 433b4b9fef..09781a0c1a 100644
--- a/src/main/java/org/openelisglobal/sample/daoimpl/DBSearchResultsDAOImpl.java
+++ b/src/main/java/org/openelisglobal/sample/daoimpl/DBSearchResultsDAOImpl.java
@@ -166,24 +166,6 @@ public List getSearchResults(String lastName, String first
"SearchResultsDAOImp:getSearchResults:query:guid: " + guid);
LogEvent.logTrace(this.getClass().getSimpleName(), "getSearchResults",
"SearchResultsDAOImp:getSearchResults:query: " + query.getQueryString());
- // String[] dArray = { " ", " ", subjectNumber, nationalID, gender, " ", " ", "
- // "};
- // String[] sArray = query.getNamedParameters();
- // for (int i = 0; i < sArray.length; i++) {
- // System.out.println(">>>: " + sArray[i] + ":" + dArray[i] );
- // }
- // System.out.println("SearchResultsDAOImp:getSearchResults:query: " +
- // "lastName" + lastName + ':' +
- // "firstName " + firstName + ':' +
- // "STNumber " + STNumber + ':' +
- // "subjectNumber " + subjectNumber + ':' +
- // "nationalID " + nationalID + ':' +
- // "externalID " + externalID + ':' +
- // "patientID " + patientID + ':' +
- // "guid " + guid + ':' +
- // "dateOfBirth " + dateOfBirth + ':' +
- // "gender " + gender
- // );
queryResults = query.list();
} catch (RuntimeException e) {
diff --git a/src/main/java/org/openelisglobal/sample/daoimpl/SampleDAOImpl.java b/src/main/java/org/openelisglobal/sample/daoimpl/SampleDAOImpl.java
index a9c685ce07..3c99fce551 100644
--- a/src/main/java/org/openelisglobal/sample/daoimpl/SampleDAOImpl.java
+++ b/src/main/java/org/openelisglobal/sample/daoimpl/SampleDAOImpl.java
@@ -32,8 +32,9 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
+import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.DateUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.sample.dao.SampleDAO;
import org.openelisglobal.sample.valueholder.OrderPriority;
import org.openelisglobal.sample.valueholder.Sample;
@@ -88,7 +89,9 @@ public List getPageOfSamples(int startingRecNo) throws LIMSRuntimeExcept
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from Sample s order by s.id";
Query query = entityManager.unwrap(Session.class).createQuery(sql, Sample.class);
@@ -353,7 +356,7 @@ public List getSamplesWithPendingQaEvents(Sample sample, boolean filterB
}
List statusesToExclude = new ArrayList<>();
- statusesToExclude.add(SystemConfiguration.getInstance().getAnalysisStatusCanceled());
+ statusesToExclude.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.canceled"));
query.setParameterList("param3", statusesToExclude);
list = query.list();
} catch (RuntimeException e) {
@@ -427,7 +430,7 @@ public List getSamplesCollectedOn(String collectionDate) throws LIMSRunt
}
private Calendar getCalendarForDateString(String recievedDate) {
- String localeName = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String localeName = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
Locale locale = new Locale(localeName);
Calendar calendar = Calendar.getInstance(locale);
diff --git a/src/main/java/org/openelisglobal/sample/form/SampleEditForm.java b/src/main/java/org/openelisglobal/sample/form/SampleEditForm.java
index 69901bc74e..a59905c665 100644
--- a/src/main/java/org/openelisglobal/sample/form/SampleEditForm.java
+++ b/src/main/java/org/openelisglobal/sample/form/SampleEditForm.java
@@ -8,7 +8,6 @@
import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.IdValuePair;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.util.validator.CustomDateValidator.DateRelation;
import org.openelisglobal.common.validator.ValidationHelper;
import org.openelisglobal.patient.action.bean.PatientSearch;
@@ -98,7 +97,7 @@ public interface SampleEdit {
private Boolean warning = false;
// in validator
- private String idSeparator = SystemConfiguration.getInstance().getDefaultIdSeparator();
+ private String idSeparator = ConfigurationProperties.getInstance().getPropertyValue("default.idSeparator");
// in validator
private String accessionFormat = ConfigurationProperties.getInstance().getPropertyValue(Property.AccessionFormat);
diff --git a/src/main/java/org/openelisglobal/sample/service/SamplePatientEntryServiceImpl.java b/src/main/java/org/openelisglobal/sample/service/SamplePatientEntryServiceImpl.java
index f21f3e8170..c49ef50f49 100644
--- a/src/main/java/org/openelisglobal/sample/service/SamplePatientEntryServiceImpl.java
+++ b/src/main/java/org/openelisglobal/sample/service/SamplePatientEntryServiceImpl.java
@@ -18,9 +18,9 @@
import org.openelisglobal.common.services.SampleAddService.SampleTestCollection;
import org.openelisglobal.common.services.StatusService.AnalysisStatus;
import org.openelisglobal.common.services.TableIdService;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.DateUtil;
import org.openelisglobal.common.util.IdValuePair;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.dataexchange.service.order.ElectronicOrderService;
import org.openelisglobal.note.service.NoteService;
import org.openelisglobal.note.service.NoteServiceImpl.NoteType;
@@ -201,7 +201,7 @@ private void persistProviderData(SamplePatientUpdateData updateData) {
}
private void persistSampleData(SamplePatientUpdateData updateData) {
- String analysisRevision = SystemConfiguration.getInstance().getAnalysisDefaultRevision();
+ String analysisRevision = ConfigurationProperties.getInstance().getPropertyValue("analysis.default.revision");
updateData.getSample().setFhirUuid(UUID.randomUUID());
sampleService.insertDataWithAccessionNumber(updateData.getSample());
diff --git a/src/main/java/org/openelisglobal/sample/validator/SampleEditFormValidator.java b/src/main/java/org/openelisglobal/sample/validator/SampleEditFormValidator.java
index 5ed26421a2..9668caeb32 100644
--- a/src/main/java/org/openelisglobal/sample/validator/SampleEditFormValidator.java
+++ b/src/main/java/org/openelisglobal/sample/validator/SampleEditFormValidator.java
@@ -9,7 +9,6 @@
import org.openelisglobal.common.provider.validation.IAccessionNumberValidator.ValidationResults;
import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.ConfigurationProperties.Property;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.util.validator.CustomDateValidator.DateRelation;
import org.openelisglobal.common.validator.ValidationHelper;
import org.openelisglobal.sample.form.SampleEditForm;
@@ -41,7 +40,7 @@ public void validate(Object target, Errors errors) {
validateSampleXML(form.getSampleXML(), errors);
ValidationHelper.validateOptionField(form.getIdSeparator(), "idSeperator", errors,
- new String[] { SystemConfiguration.getInstance().getDefaultIdSeparator() });
+ new String[] { ConfigurationProperties.getInstance().getPropertyValue("default.idSeparator") });
ValidationHelper.validateOptionField(form.getAccessionFormat(), "accessionFormat", errors,
new String[] { ConfigurationProperties.getInstance().getPropertyValue(Property.AccessionFormat) });
diff --git a/src/main/java/org/openelisglobal/sample/valueholder/Sample.java b/src/main/java/org/openelisglobal/sample/valueholder/Sample.java
index 7c21d2b6d0..54f8ae35bb 100644
--- a/src/main/java/org/openelisglobal/sample/valueholder/Sample.java
+++ b/src/main/java/org/openelisglobal/sample/valueholder/Sample.java
@@ -19,8 +19,9 @@
import java.util.List;
import java.util.UUID;
import org.apache.commons.validator.GenericValidator;
+import org.openelisglobal.common.util.ConfigurationProperties;
+import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.DateUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.valueholder.EnumValueItemImpl;
import org.openelisglobal.common.valueholder.ValueHolder;
import org.openelisglobal.common.valueholder.ValueHolderInterface;
@@ -292,7 +293,7 @@ public String getReleasedDateForDisplay() {
public void setReleasedDateForDisplay(String releasedDateForDisplay) {
this.releasedDateForDisplay = releasedDateForDisplay;
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
releasedDate = DateUtil.convertStringDateToSqlDate(releasedDateForDisplay, locale);
}
@@ -306,7 +307,7 @@ public String getTransmissionDateForDisplay() {
public void setTransmissionDateForDisplay(String transmissionDateForDisplay) {
this.transmissionDateForDisplay = transmissionDateForDisplay;
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
transmissionDate = DateUtil.convertStringDateToSqlDate(transmissionDateForDisplay, locale);
}
diff --git a/src/main/java/org/openelisglobal/sampleitem/daoimpl/SampleItemDAOImpl.java b/src/main/java/org/openelisglobal/sampleitem/daoimpl/SampleItemDAOImpl.java
index aaab9f7c25..a43cb50439 100644
--- a/src/main/java/org/openelisglobal/sampleitem/daoimpl/SampleItemDAOImpl.java
+++ b/src/main/java/org/openelisglobal/sampleitem/daoimpl/SampleItemDAOImpl.java
@@ -26,7 +26,7 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.sampleitem.dao.SampleItemDAO;
import org.openelisglobal.sampleitem.valueholder.SampleItem;
import org.openelisglobal.sourceofsample.valueholder.SourceOfSample;
@@ -96,7 +96,9 @@ public List getPageOfSampleItems(int startingRecNo) throws LIMSRunti
List list;
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
String sql = "from SampleItem s order by s.id";
Query query = entityManager.unwrap(Session.class).createQuery(sql, SampleItem.class);
diff --git a/src/main/java/org/openelisglobal/sampleqaevent/valueholder/SampleQaEvent.java b/src/main/java/org/openelisglobal/sampleqaevent/valueholder/SampleQaEvent.java
index a454a17fa4..f44e63c22e 100644
--- a/src/main/java/org/openelisglobal/sampleqaevent/valueholder/SampleQaEvent.java
+++ b/src/main/java/org/openelisglobal/sampleqaevent/valueholder/SampleQaEvent.java
@@ -16,8 +16,9 @@
import java.sql.Date;
import java.sql.Timestamp;
import org.openelisglobal.common.services.QAService;
+import org.openelisglobal.common.util.ConfigurationProperties;
+import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.DateUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.valueholder.BaseObject;
import org.openelisglobal.common.valueholder.ValueHolder;
import org.openelisglobal.common.valueholder.ValueHolderInterface;
@@ -135,7 +136,7 @@ public String getCompletedDateForDisplay() {
public void setCompletedDateForDisplay(String completedDateForDisplay) {
this.completedDateForDisplay = completedDateForDisplay;
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
completedDate = DateUtil.convertStringDateToSqlDate(completedDateForDisplay, locale);
}
diff --git a/src/main/java/org/openelisglobal/sampleqaeventaction/valueholder/SampleQaEventAction.java b/src/main/java/org/openelisglobal/sampleqaeventaction/valueholder/SampleQaEventAction.java
index 574ed5b52a..33f6362e7d 100644
--- a/src/main/java/org/openelisglobal/sampleqaeventaction/valueholder/SampleQaEventAction.java
+++ b/src/main/java/org/openelisglobal/sampleqaeventaction/valueholder/SampleQaEventAction.java
@@ -15,8 +15,9 @@
import java.sql.Date;
import org.openelisglobal.action.valueholder.Action;
+import org.openelisglobal.common.util.ConfigurationProperties;
+import org.openelisglobal.common.util.ConfigurationProperties.Property;
import org.openelisglobal.common.util.DateUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.common.valueholder.BaseObject;
import org.openelisglobal.common.valueholder.ValueHolder;
import org.openelisglobal.common.valueholder.ValueHolderInterface;
@@ -127,7 +128,7 @@ public String getCreatedDateForDisplay() {
public void setCreatedDateForDisplay(String createdDateForDisplay) {
this.createdDateForDisplay = createdDateForDisplay;
// also update the java.sql.Date
- String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
+ String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
this.createdDate = DateUtil.convertStringDateToSqlDate(createdDateForDisplay, locale);
}
diff --git a/src/main/java/org/openelisglobal/scriptlet/daoimpl/ScriptletDAOImpl.java b/src/main/java/org/openelisglobal/scriptlet/daoimpl/ScriptletDAOImpl.java
index 908d9b62f4..90c29ee9a3 100644
--- a/src/main/java/org/openelisglobal/scriptlet/daoimpl/ScriptletDAOImpl.java
+++ b/src/main/java/org/openelisglobal/scriptlet/daoimpl/ScriptletDAOImpl.java
@@ -22,8 +22,8 @@
import org.openelisglobal.common.daoimpl.BaseDAOImpl;
import org.openelisglobal.common.exception.LIMSRuntimeException;
import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
-import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.scriptlet.dao.ScriptletDAO;
import org.openelisglobal.scriptlet.valueholder.Scriptlet;
import org.springframework.stereotype.Component;
@@ -82,7 +82,9 @@ public List getPageOfScriptlets(int startingRecNo) throws LIMSRuntime
List list;
try {
// calculate maxRow to be one more than the page size
- int endingRecNo = startingRecNo + (SystemConfiguration.getInstance().getDefaultPageSize() + 1);
+ int endingRecNo = startingRecNo
+ + (Integer.parseInt(ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"))
+ + 1);
// bugzilla 1399
String sql = "from Scriptlet s order by s.scriptletName";
diff --git a/src/main/java/org/openelisglobal/security/SecurityConfig.java b/src/main/java/org/openelisglobal/security/SecurityConfig.java
index 4934508ad4..930e185ac5 100644
--- a/src/main/java/org/openelisglobal/security/SecurityConfig.java
+++ b/src/main/java/org/openelisglobal/security/SecurityConfig.java
@@ -12,6 +12,7 @@
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -23,22 +24,33 @@
import org.openelisglobal.security.login.BasicAuthFilter;
import org.openelisglobal.security.login.CustomAuthenticationFailureHandler;
import org.openelisglobal.security.login.CustomFormAuthenticationSuccessHandler;
+import org.openelisglobal.security.login.CustomSSOAuthenticationSuccessHandler;
import org.openelisglobal.spring.util.SpringContext;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.core.xml.schema.XSString;
+import org.opensaml.saml.saml2.core.Assertion;
+import org.opensaml.saml.saml2.core.Attribute;
+import org.opensaml.saml.saml2.core.AttributeStatement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.annotation.Order;
+import org.springframework.core.convert.converter.Converter;
import org.springframework.core.io.Resource;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationProvider;
+import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.core.AuthenticatedPrincipal;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
@@ -49,8 +61,13 @@
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.oauth2.client.registration.ClientRegistrations;
import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository;
+import org.springframework.security.saml2.core.Saml2ResponseValidatorResult;
import org.springframework.security.saml2.core.Saml2X509Credential;
import org.springframework.security.saml2.core.Saml2X509Credential.Saml2X509CredentialType;
+import org.springframework.security.saml2.provider.service.authentication.OpenSaml4AuthenticationProvider;
+import org.springframework.security.saml2.provider.service.authentication.OpenSaml4AuthenticationProvider.AssertionToken;
+import org.springframework.security.saml2.provider.service.authentication.OpenSaml4AuthenticationProvider.ResponseToken;
+import org.springframework.security.saml2.provider.service.authentication.Saml2Authentication;
import org.springframework.security.saml2.provider.service.registration.InMemoryRelyingPartyRegistrationRepository;
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration;
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository;
@@ -99,6 +116,12 @@ public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Ex
auth.authenticationProvider(authenticationProvider());
}
+ @Bean
+ public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration)
+ throws Exception {
+ return authenticationConfiguration.getAuthenticationManager();
+ }
+
@Configuration
@Order(1)
public static class openSecurityConfiguration extends WebSecurityConfigurerAdapter {
@@ -229,16 +252,33 @@ protected void configure(HttpSecurity http) throws Exception {
MultipartFilter multipartFilter = new MultipartFilter();
multipartFilter.setServletContext(SpringContext.getBean(ServletContext.class));
http.addFilterBefore(multipartFilter, CsrfFilter.class);
-
+ OpenSaml4AuthenticationProvider authenticationProvider = new OpenSaml4AuthenticationProvider();
+ Converter delegate = OpenSaml4AuthenticationProvider
+ .createDefaultResponseAuthenticationConverter();
+ authenticationProvider
+ .setAssertionValidator(OpenSaml4AuthenticationProvider.createDefaultAssertionValidator());
+ authenticationProvider.setResponseAuthenticationConverter(responseToken -> {
+
+ Saml2Authentication authentication = delegate.convert(responseToken);
+ Assertion assertion = responseToken.getResponse().getAssertions().get(0);
+ AuthenticatedPrincipal principal = (AuthenticatedPrincipal) authentication.getPrincipal();
+ Collection authorities = new KeycloakAuthoritiesExtractor().convert(assertion);
+
+ return new Saml2Authentication(principal, authentication.getSaml2Response(), authorities);
+ });
+ Converter validator = OpenSaml4AuthenticationProvider
+ .createDefaultAssertionValidator();
+ authenticationProvider.setAssertionValidator(validator);
http.requestMatcher(new SamlRequestedMatcher()).authorizeRequests().anyRequest().authenticated().and()
- .saml2Logout().and().saml2Login().failureHandler(customAuthenticationFailureHandler())
+ .saml2Logout().and().saml2Login().authenticationManager(new ProviderManager(authenticationProvider))
+ .failureHandler(customAuthenticationFailureHandler())
.successHandler(customAuthenticationSuccessHandler())
.relyingPartyRegistrationRepository(relyingPartyRegistrationRepository());
}
@Bean("samlAuthenticationSuccessHandler")
public AuthenticationSuccessHandler customAuthenticationSuccessHandler() {
- return new CustomFormAuthenticationSuccessHandler();
+ return new CustomSSOAuthenticationSuccessHandler();
}
@Bean("samlAuthenticationFailureHandler")
@@ -256,6 +296,7 @@ public static class openidSecurityConfiguration extends WebSecurityConfigurerAda
private String config;
@Value("${org.itech.login.oauth.clientID:OpenELIS-Global_oauth}")
+
private String clientID;
@Value("${org.itech.login.oauth.clientSecret:}")
@@ -341,6 +382,7 @@ protected void configure(HttpSecurity http) throws Exception {
}
@Configuration
+ @ConditionalOnProperty(property = "org.itech.login.form", havingValue = "true", matchIfMissing = true)
public static class defaultSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
@@ -380,12 +422,6 @@ public AuthenticationFailureHandler customAuthenticationFailureHandler() {
public AuthenticationSuccessHandler customAuthenticationSuccessHandler() {
return new CustomFormAuthenticationSuccessHandler();
}
-
- @Bean
- public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration)
- throws Exception {
- return authenticationConfiguration.getAuthenticationManager();
- }
}
// @Bean
@@ -477,4 +513,26 @@ public boolean matches(HttpServletRequest request) {
return haveCertificateAuth;
}
}
+
+ private static class KeycloakAuthoritiesExtractor {
+
+ // TODO should we use authority AND Role? (Spring Concepts)
+ public Collection convert(Assertion assertion) {
+ Collection authorties = new ArrayList<>();
+ for (AttributeStatement statement : assertion.getAttributeStatements()) {
+ for (Attribute attr : statement.getAttributes()) {
+ if ("Role".equals(attr.getName())) {
+ for (XMLObject attributeValue : attr.getAttributeValues()) {
+ String value = ((XSString) attributeValue).getValue();
+ if (value != null && value.startsWith("oeg-")) {
+ authorties.add(new SimpleGrantedAuthority(value));
+ }
+
+ }
+ }
+ }
+ }
+ return authorties;
+ }
+ }
}
diff --git a/src/main/java/org/openelisglobal/security/login/BasicAuthFilter.java b/src/main/java/org/openelisglobal/security/login/BasicAuthFilter.java
index 161fa567b4..3066ef4554 100644
--- a/src/main/java/org/openelisglobal/security/login/BasicAuthFilter.java
+++ b/src/main/java/org/openelisglobal/security/login/BasicAuthFilter.java
@@ -5,7 +5,7 @@
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.openelisglobal.common.action.IActionConstants;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.login.service.LoginUserService;
import org.openelisglobal.login.valueholder.LoginUser;
import org.openelisglobal.login.valueholder.UserSessionData;
@@ -58,7 +58,7 @@ private void setupUserRequest(HttpServletRequest request, LoginUser loginInfo) {
request.getSession().setAttribute(IActionConstants.USER_SESSION_DATA, usd);
// get permitted actions map (available modules for the current user)
- if (SystemConfiguration.getInstance().getPermissionAgent().equals("ROLE")) {
+ if (ConfigurationProperties.getInstance().getPropertyValue("permissions.agent").equalsIgnoreCase("ROLE")) {
Set permittedPages = getPermittedForms(usd.getSystemUserId());
request.setAttribute(IActionConstants.PERMITTED_ACTIONS_MAP, permittedPages);
// showAdminMenu |= permittedPages.contains("MasterList");
diff --git a/src/main/java/org/openelisglobal/security/login/CustomFormAuthenticationSuccessHandler.java b/src/main/java/org/openelisglobal/security/login/CustomFormAuthenticationSuccessHandler.java
index 516d8c3099..48372235ca 100644
--- a/src/main/java/org/openelisglobal/security/login/CustomFormAuthenticationSuccessHandler.java
+++ b/src/main/java/org/openelisglobal/security/login/CustomFormAuthenticationSuccessHandler.java
@@ -14,7 +14,7 @@
import org.openelisglobal.common.action.IActionConstants;
import org.openelisglobal.common.constants.Constants;
import org.openelisglobal.common.log.LogEvent;
-import org.openelisglobal.common.util.SystemConfiguration;
+import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.validator.BaseErrors;
import org.openelisglobal.login.service.LoginUserService;
import org.openelisglobal.login.valueholder.LoginUser;
@@ -29,8 +29,6 @@
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
-import org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal;
import org.springframework.security.web.WebAttributes;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
@@ -84,16 +82,6 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
if (principal instanceof UserDetails) {
UserDetails user = (UserDetails) principal;
loginInfo = loginService.getUserProfile(user.getUsername());
- } else if (principal instanceof DefaultSaml2AuthenticatedPrincipal) {
- DefaultSaml2AuthenticatedPrincipal samlUser = (DefaultSaml2AuthenticatedPrincipal) principal;
- loginInfo = loginService.getUserProfile(samlUser.getName());
- request.getSession().setAttribute("samlSession", true);
- samlLogin = true;
- } else if (principal instanceof DefaultOAuth2User) {
- DefaultOAuth2User oauthUser = (DefaultOAuth2User) principal;
- loginInfo = loginService.getUserProfile(oauthUser.getAttribute("preferred_username"));
- request.getSession().setAttribute("oauthSession", true);
- oauthLogin = true;
}
}
try {
@@ -171,7 +159,7 @@ private void setupUserSession(HttpServletRequest request, LoginUser loginInfo) {
request.getSession().setAttribute("timezone", timezone);
// get permitted actions map (available modules for the current user)
- if (SystemConfiguration.getInstance().getPermissionAgent().equals("ROLE")) {
+ if (ConfigurationProperties.getInstance().getPropertyValue("permissions.agent").equalsIgnoreCase("ROLE")) {
Set permittedPages = getPermittedForms(usd.getSystemUserId());
request.getSession().setAttribute(IActionConstants.PERMITTED_ACTIONS_MAP, permittedPages);
// showAdminMenu |= permittedPages.contains("MasterList");
@@ -194,9 +182,9 @@ private Set getPermittedForms(int systemUserId) {
private boolean passwordExpiringSoon(LoginUser loginInfo) {
return loginInfo.getPasswordExpiredDayNo() <= Integer
- .parseInt(SystemConfiguration.getInstance().getLoginUserPasswordExpiredReminderDay())
- && (loginInfo.getPasswordExpiredDayNo() > Integer
- .parseInt(SystemConfiguration.getInstance().getLoginUserChangePasswordAllowDay()));
+ .parseInt(ConfigurationProperties.getInstance().getPropertyValue("login.user.expired.reminder.day"))
+ && (loginInfo.getPasswordExpiredDayNo() > Integer.parseInt(
+ ConfigurationProperties.getInstance().getPropertyValue("login.user.change.allow.day")));
}
protected void clearCustomAuthenticationAttributes(HttpServletRequest request) {
diff --git a/src/main/java/org/openelisglobal/security/login/CustomSSOAuthenticationSuccessHandler.java b/src/main/java/org/openelisglobal/security/login/CustomSSOAuthenticationSuccessHandler.java
new file mode 100644
index 0000000000..2e23ac81fa
--- /dev/null
+++ b/src/main/java/org/openelisglobal/security/login/CustomSSOAuthenticationSuccessHandler.java
@@ -0,0 +1,381 @@
+package org.openelisglobal.security.login;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.json.JSONObject;
+import org.openelisglobal.common.action.IActionConstants;
+import org.openelisglobal.common.constants.Constants;
+import org.openelisglobal.common.log.LogEvent;
+import org.openelisglobal.common.util.ConfigurationProperties;
+import org.openelisglobal.common.util.validator.GenericValidator;
+import org.openelisglobal.common.validator.BaseErrors;
+import org.openelisglobal.login.valueholder.LoginUser;
+import org.openelisglobal.login.valueholder.UserSessionData;
+import org.openelisglobal.role.service.RoleService;
+import org.openelisglobal.role.valueholder.Role;
+import org.openelisglobal.systemuser.service.SystemUserService;
+import org.openelisglobal.systemuser.valueholder.SystemUser;
+import org.openelisglobal.systemusermodule.service.PermissionModuleService;
+import org.openelisglobal.systemusermodule.valueholder.PermissionModule;
+import org.openelisglobal.userrole.service.UserRoleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
+import org.springframework.security.saml2.provider.service.authentication.DefaultSaml2AuthenticatedPrincipal;
+import org.springframework.security.web.WebAttributes;
+import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
+import org.springframework.stereotype.Component;
+import org.springframework.validation.Errors;
+import org.springframework.web.servlet.support.RequestContextUtils;
+
+@Component
+public class CustomSSOAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler
+ implements IActionConstants {
+ @Autowired
+ private UserRoleService userRoleService;
+ @Autowired
+ private PermissionModuleService permissionModuleService;
+ @Autowired
+ private SystemUserService systemUserService;
+ @Autowired
+ private RoleService roleService;
+
+ @Value("${org.openelisglobal.timezone:}")
+ private String timezone;
+
+ public static final int DEFAULT_SESSION_TIMEOUT_IN_MINUTES = 20;
+
+ public CustomSSOAuthenticationSuccessHandler() {
+ super();
+ }
+
+ @Override
+ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
+ Authentication authentication) throws IOException, ServletException {
+ // get the X-Forwarded-For header so that we know if the request is from a proxy
+ final String xfHeader = request.getHeader("X-Forwarded-For");
+ if (xfHeader == null) {
+ // no proxy
+ LogEvent.logInfo(this.getClass().getSimpleName(), "onSuccess",
+ "Successful login attempt for " + authentication.getName() + " from " + request.getRemoteAddr());
+ } else {
+ // from proxy
+ LogEvent.logInfo(this.getClass().getSimpleName(), "onSuccess",
+ "Successful login attempt for " + authentication.getName() + " from " + xfHeader.split(",")[0]);
+ }
+
+ // String homePath = "/Dashboard";
+ // LoginUser loginInfo = null;
+ boolean apiLogin = "true".equals(request.getParameter("apiCall"));
+ boolean samlLogin = false;
+ boolean oauthLogin = false;
+
+ SecurityContextHolder.getContext().setAuthentication(authentication);
+ if (authentication != null) {
+ Object principal = authentication.getPrincipal();
+
+ if (principal instanceof DefaultSaml2AuthenticatedPrincipal) {
+ DefaultSaml2AuthenticatedPrincipal samlUser = (DefaultSaml2AuthenticatedPrincipal) principal;
+ // loginInfo = loginService.getUserProfile(samlUser.getName());
+ request.getSession().setAttribute("samlSession", true);
+ samlLogin = true;
+ try {
+
+ setupUserSession(request, samlUser);
+ } catch (IllegalStateException e) {
+ LogEvent.logError(this.getClass().getSimpleName(), "onAuthenticationSuccess",
+ "the login user doesn't exist in OE this is usually caused by login being handled by an"
+ + " external application that contains a user that OE is missing");
+ SecurityContextHolder.getContext().setAuthentication(null);
+ BaseErrors errors = new BaseErrors();
+ errors.reject("login.error.noOeUser");
+
+ request.getSession().setAttribute(Constants.LOGIN_ERRORS, errors);
+ getRedirectStrategy().sendRedirect(request, response, "/LoginPage");
+ return;
+ } catch (RuntimeException e) {
+ LogEvent.logError(e);
+
+ SecurityContextHolder.getContext().setAuthentication(null);
+ BaseErrors errors = new BaseErrors();
+ errors.reject("login.error.sessionsetup");
+
+ request.getSession().setAttribute(Constants.LOGIN_ERRORS, errors);
+ getRedirectStrategy().sendRedirect(request, response, "/LoginPage");
+ return;
+ }
+ } else if (principal instanceof DefaultOAuth2User) {
+ DefaultOAuth2User oauthUser = (DefaultOAuth2User) principal;
+ // loginInfo =
+ // loginService.getUserProfile(oauthUser.getAttribute("preferred_username"));
+ request.getSession().setAttribute("oauthSession", true);
+ oauthLogin = true;
+ try {
+ setupUserSession(request, oauthUser);
+ } catch (IllegalStateException e) {
+ LogEvent.logError(this.getClass().getSimpleName(), "onAuthenticationSuccess",
+ "the login user doesn't exist in OE this is usually caused by login being handled by an"
+ + " external application that contains a user that OE is missing");
+ SecurityContextHolder.getContext().setAuthentication(null);
+ BaseErrors errors = new BaseErrors();
+ errors.reject("login.error.noOeUser");
+
+ request.getSession().setAttribute(Constants.LOGIN_ERRORS, errors);
+ getRedirectStrategy().sendRedirect(request, response, "/LoginPage");
+ return;
+ } catch (RuntimeException e) {
+ LogEvent.logError(e);
+
+ SecurityContextHolder.getContext().setAuthentication(null);
+ BaseErrors errors = new BaseErrors();
+ errors.reject("login.error.sessionsetup");
+
+ request.getSession().setAttribute(Constants.LOGIN_ERRORS, errors);
+ getRedirectStrategy().sendRedirect(request, response, "/LoginPage");
+ return;
+ }
+
+ }
+ }
+
+ // if (passwordExpiringSoon(loginInfo)) {
+ // homePath += "?passReminder=true";
+ // }
+
+ if (apiLogin) {
+ request.getSession().setAttribute("login_method", "form");
+ this.handleApiLogin(request, response);
+ } else if (samlLogin) {
+ request.getSession().setAttribute("login_method", "samlLogin");
+ this.handleApiLogin(request, response);
+ } else if (oauthLogin) {
+ request.getSession().setAttribute("login_method", "oauthLogin");
+ this.handleApiLogin(request, response);
+ } else {
+ // redirectStrategy.sendRedirect(request, response, homePath);
+ super.onAuthenticationSuccess(request, response, authentication);
+ clearCustomAuthenticationAttributes(request);
+ }
+ }
+
+ private void handleApiLogin(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ PrintWriter out = response.getWriter();
+ response.setContentType("application/json");
+
+ out.print(new JSONObject().put("success", true));
+ }
+
+ private void setupUserSession(HttpServletRequest request, DefaultSaml2AuthenticatedPrincipal principal) {
+ int timeout;
+
+ Collection extends GrantedAuthority> authorities = SecurityContextHolder.getContext().getAuthentication()
+ .getAuthorities();
+
+ boolean isAdmin = false;
+ for (GrantedAuthority authority : authorities) {
+ String[] authorityExplode = authority.getAuthority().split("-");
+ if (authorityExplode.length >= 2) {
+ isAdmin = "admin".equalsIgnoreCase(authorityExplode[1]);
+ }
+ }
+ // if (loginInfo == null) {
+ // throw new IllegalStateException("no loginUser during user session setup");
+ // }
+ // if (loginInfo.getUserTimeOut() != null) {
+ // timeout = Integer.parseInt(loginInfo.getUserTimeOut()) * 60;
+ // } else {
+ // timeout = DEFAULT_SESSION_TIMEOUT_IN_MINUTES * 60;
+ // }
+ request.getSession().setMaxInactiveInterval(DEFAULT_SESSION_TIMEOUT_IN_MINUTES * 60);
+
+ // get system user and link to login user
+ // SystemUser su =
+ // systemUserService.get(String.valueOf(loginInfo.getSystemUserId()));
+ // create usersessiondata and store in session
+ UserSessionData usd = new UserSessionData();
+
+ Optional user = systemUserService.getMatch("loginName", principal.getName());
+
+ SystemUser systemUser = new SystemUser();
+ if (user.isEmpty()) {
+ systemUser.setFirstName(principal.getName());
+ systemUser.setLastName("");
+ systemUser.setLoginName(principal.getName());
+ systemUser.setIsActive("Y");
+ systemUser.setIsEmployee("Y");
+ systemUser.setExternalId("1");
+ String initial = (GenericValidator.isBlankOrNull(systemUser.getFirstName()) ? ""
+ : systemUser.getFirstName().substring(0, 1))
+ + (GenericValidator.isBlankOrNull(systemUser.getLastName()) ? ""
+ : systemUser.getLastName().substring(0, 1));
+ systemUser.setInitials(initial);
+ systemUser.setSysUserId("1");
+
+ systemUser = systemUserService.save(systemUser);
+ } else {
+ systemUser = user.get();
+ }
+ usd.setSytemUserId(Integer.parseInt(systemUser.getId()));
+ usd.setLoginName(principal.getName());
+ // usd.setElisUserName(su.getNameForDisplay());
+ usd.setElisUserName(principal.getName());
+ usd.setUserTimeOut(DEFAULT_SESSION_TIMEOUT_IN_MINUTES * 60);
+ usd.setAdmin(isAdmin);
+ request.getSession().setAttribute(IActionConstants.USER_SESSION_DATA, usd);
+ request.getSession().setAttribute("timezone", timezone);
+
+ // get permitted actions map (available modules for the current user)
+ if (ConfigurationProperties.getInstance().getPropertyValue("permissions.agent").equalsIgnoreCase("ROLE")) {
+ Set permittedPages = getPermittedForms(authorities);
+ request.getSession().setAttribute(IActionConstants.PERMITTED_ACTIONS_MAP, permittedPages);
+ // showAdminMenu |= permittedPages.contains("MasterList");
+ }
+ }
+
+ private void setupUserSession(HttpServletRequest request, DefaultOAuth2User principal) {
+ Collection extends GrantedAuthority> authorities = SecurityContextHolder.getContext().getAuthentication()
+ .getAuthorities();
+
+ boolean isAdmin = false;
+ for (GrantedAuthority authority : authorities) {
+ String[] authorityExplode = authority.getAuthority().split("-");
+ if (authorityExplode.length >= 2) {
+ isAdmin = "admin".equalsIgnoreCase(authorityExplode[1]);
+ }
+ }
+ request.getSession().setMaxInactiveInterval(DEFAULT_SESSION_TIMEOUT_IN_MINUTES * 60);
+
+ UserSessionData usd = new UserSessionData();
+ Optional user = systemUserService.getMatch("loginName", principal.getName());
+ SystemUser systemUser = new SystemUser();
+ if (user.isEmpty()) {
+ systemUser.setFirstName(principal.getName());
+ systemUser.setLastName("");
+ systemUser.setLoginName(principal.getName());
+ systemUser.setIsActive("Y");
+ systemUser.setIsEmployee("Y");
+ systemUser.setExternalId("1");
+ String initial = systemUser.getFirstName().substring(0, 1) + systemUser.getLastName().substring(0, 1);
+ systemUser.setInitials(initial);
+ systemUser.setSysUserId("1");
+
+ systemUser = systemUserService.save(systemUser);
+ }
+ usd.setSytemUserId(Integer.parseInt(systemUser.getId()));
+ usd.setLoginName(principal.getName());
+ // usd.setElisUserName(su.getNameForDisplay());
+ usd.setElisUserName(principal.getName());
+ usd.setUserTimeOut(DEFAULT_SESSION_TIMEOUT_IN_MINUTES * 60);
+ usd.setAdmin(isAdmin);
+ request.getSession().setAttribute("authorities", usd);
+ request.getSession().setAttribute(IActionConstants.USER_SESSION_DATA, usd);
+ request.getSession().setAttribute("timezone", timezone);
+
+ // get permitted actions map (available modules for the current user)
+ if (ConfigurationProperties.getInstance().getPropertyValue("permissions.agent").equalsIgnoreCase("ROLE")) {
+ Set permittedPages = getPermittedForms(authorities);
+ request.getSession().setAttribute(IActionConstants.PERMITTED_ACTIONS_MAP, permittedPages);
+ // showAdminMenu |= permittedPages.contains("MasterList");
+ }
+ }
+
+ private Set getPermittedForms(Collection extends GrantedAuthority> authorities) {
+ Set allPermittedPages = new HashSet<>();
+
+ // List