Skip to content

Commit

Permalink
remove redundant system config class
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebSLane committed Oct 8, 2024
1 parent 28f7601 commit e2b289a
Show file tree
Hide file tree
Showing 107 changed files with 703 additions and 1,829 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import org.openelisglobal.common.log.LogEvent;
import org.openelisglobal.common.services.IStatusService;
import org.openelisglobal.common.services.StatusService.AnalysisStatus;
import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.StringUtil;
import org.openelisglobal.common.util.SystemConfiguration;
import org.openelisglobal.result.valueholder.Result;
import org.openelisglobal.sample.valueholder.OrderPriority;
import org.openelisglobal.sample.valueholder.Sample;
Expand Down Expand Up @@ -444,11 +444,14 @@ public List<Analysis> getAnalysesByPriorityAndStatusId(OrderPriority priority, L
public List<Analysis> getAnalysesReadyToBeReported() throws LIMSRuntimeException {
try {
List<String> analysisStatusesToInclude = new ArrayList<>();
analysisStatusesToInclude.add(SystemConfiguration.getInstance().getAnalysisStatusReleased());
analysisStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.released"));

List<String> sampleStatusesToInclude = new ArrayList<>();
sampleStatusesToInclude.add(SystemConfiguration.getInstance().getSampleStatusEntry2Complete());
sampleStatusesToInclude.add(SystemConfiguration.getInstance().getSampleStatusReleased());
sampleStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("sample.status.entry.2.complete"));
sampleStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("sample.status.released"));

String sql = "select distinct anal.id\n" + " from\n" + " sample samp,\n"
+ " test_analyte ta,\n" + " analysis anal,\n"
Expand Down Expand Up @@ -497,7 +500,7 @@ public List<Analysis> getAllChildAnalysesByResult(Result result) throws LIMSRunt
Query<Analysis> query = entityManager.unwrap(Session.class).createQuery(sql, Analysis.class);
query.setParameter("param", result.getId());
List<String> statusesToExclude = new ArrayList<>();
statusesToExclude.add(SystemConfiguration.getInstance().getAnalysisStatusCanceled());
statusesToExclude.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.canceled"));
query.setParameterList("param2", statusesToExclude);
return query.list();
} catch (RuntimeException e) {
Expand All @@ -518,7 +521,7 @@ public List<Analysis> getMaxRevisionAnalysesBySample(SampleItem sampleItem) thro
Query<Analysis> query = entityManager.unwrap(Session.class).createQuery(sql, Analysis.class);
query.setParameter("param", sampleItem.getId());
List<String> statusesToExclude = new ArrayList<>();
statusesToExclude.add(SystemConfiguration.getInstance().getAnalysisStatusCanceled());
statusesToExclude.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.canceled"));
query.setParameterList("param2", statusesToExclude);
return query.list();
} catch (RuntimeException e) {
Expand Down Expand Up @@ -561,7 +564,7 @@ public List<Analysis> getRevisionHistoryOfAnalysesBySample(SampleItem sampleItem
Query<Analysis> query = entityManager.unwrap(Session.class).createQuery(sql, Analysis.class);
query.setParameter("param", sampleItem.getId());
List<String> statusesToExclude = new ArrayList<>();
statusesToExclude.add(SystemConfiguration.getInstance().getAnalysisStatusCanceled());
statusesToExclude.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.canceled"));
query.setParameterList("param2", statusesToExclude);
return query.list();
} catch (RuntimeException e) {
Expand Down Expand Up @@ -591,7 +594,7 @@ public List<Analysis> getRevisionHistoryOfAnalysesBySampleAndTest(SampleItem sam
query.setParameter("param", sampleItem.getId());
query.setParameter("param2", test.getId());
List<String> statusesToExclude = new ArrayList<>();
statusesToExclude.add(SystemConfiguration.getInstance().getAnalysisStatusCanceled());
statusesToExclude.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.canceled"));
query.setParameterList("param3", statusesToExclude);
return query.list();
} catch (RuntimeException e) {
Expand All @@ -613,7 +616,7 @@ public List<Analysis> getAllMaxRevisionAnalysesPerTest(Test test) throws LIMSRun
query.setParameter("param", test.getId());

List<String> statusesToExclude = new ArrayList<>();
statusesToExclude.add(SystemConfiguration.getInstance().getAnalysisStatusCanceled());
statusesToExclude.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.canceled"));
query.setParameterList("param2", statusesToExclude);

return query.list();
Expand All @@ -629,11 +632,14 @@ public List<Analysis> getAllMaxRevisionAnalysesPerTest(Test test) throws LIMSRun
public List<Analysis> getMaxRevisionAnalysesReadyToBeReported() throws LIMSRuntimeException {
try {
List<String> analysisStatusesToInclude = new ArrayList<>();
analysisStatusesToInclude.add(SystemConfiguration.getInstance().getAnalysisStatusReleased());
analysisStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.released"));

List<String> sampleStatusesToInclude = new ArrayList<>();
sampleStatusesToInclude.add(SystemConfiguration.getInstance().getSampleStatusEntry2Complete());
sampleStatusesToInclude.add(SystemConfiguration.getInstance().getSampleStatusReleased());
sampleStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("sample.status.entry.2.complete"));
sampleStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("sample.status.released"));

String sql = "select distinct anal.id\n" + " from\n" + " sample samp,\n"
+ " test_analyte ta,\n" + " analysis anal,\n"
Expand Down Expand Up @@ -689,12 +695,15 @@ public List<Analysis> getMaxRevisionAnalysesReadyForReportPreviewBySample(List<S
// see question in 1900 should this be released or results completed
// status?
// answer: results completed
analysisStatusesToInclude.add(SystemConfiguration.getInstance().getAnalysisStatusResultCompleted());
analysisStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.result.completed"));

List<String> sampleStatusesToInclude = new ArrayList<>();
sampleStatusesToInclude.add(SystemConfiguration.getInstance().getSampleStatusEntry2Complete());
sampleStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("sample.status.entry.2.complete"));
// see question in 1900 - should this be included? Yes
sampleStatusesToInclude.add(SystemConfiguration.getInstance().getSampleStatusReleased());
sampleStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("sample.status.released"));

if (accessionNumbers != null && accessionNumbers.size() > 0) {
String sql = "select distinct anal.id\n" + " from\n" + " sample samp,\n"
Expand Down Expand Up @@ -779,10 +788,12 @@ public List<Analysis> getMaxRevisionPendingAnalysesReadyToBeReportedBySample(Sam
throws LIMSRuntimeException {
try {
List<String> analysisStatusesToInclude = new ArrayList<>();
analysisStatusesToInclude.add(SystemConfiguration.getInstance().getAnalysisStatusAssigned());
analysisStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.assigned"));
// bugzilla 2264 per Nancy add results completed status to pending
// tests
analysisStatusesToInclude.add(SystemConfiguration.getInstance().getAnalysisStatusResultCompleted());
analysisStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.result.completed"));

String sql = "select\n" + " distinct anal.id\n" + " from\n" + " sample_item sampitem,\n"
+ " sample samp,\n" + " analysis anal,\n" + " test test\n" + "\n" + " where\n"
Expand Down Expand Up @@ -830,10 +841,11 @@ public List<Analysis> getMaxRevisionPendingAnalysesReadyForReportPreviewBySample
try {

List<String> analysisStatusesToInclude = new ArrayList<>();
analysisStatusesToInclude.add(SystemConfiguration.getInstance().getAnalysisStatusAssigned());
analysisStatusesToInclude
.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.assigned"));
// see question in 1900 do we need to include this?
// Answer NO
// analysisStatusesToInclude.add(SystemConfiguration.getInstance().getAnalysisStatusResultCompleted());
// analysisStatusesToInclude.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.result.completed"));

list = entityManager.unwrap(Session.class)
.getNamedQuery("analysis.getMaxRevisionPendingAnalysesReadyToBeReportedBySample")
Expand Down Expand Up @@ -876,7 +888,7 @@ public Analysis getPreviousAnalysisForAmendedAnalysis(Analysis analysis) throws
query.setParameter("param3", analysis.getTest());

List<String> statusesToExclude = new ArrayList<>();
statusesToExclude.add(SystemConfiguration.getInstance().getAnalysisStatusCanceled());
statusesToExclude.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.canceled"));
query.setParameterList("param4", statusesToExclude);
List<Analysis> list = query.list();
if ((list != null) && !list.isEmpty()) {
Expand Down Expand Up @@ -906,7 +918,7 @@ public void getMaxRevisionAnalysisBySampleAndTest(Analysis analysis) throws LIMS
query.setParameter("param", analysis.getSampleItem().getId());
query.setParameter("param2", analysis.getTest().getId());
List<String> statusesToExclude = new ArrayList<>();
statusesToExclude.add(SystemConfiguration.getInstance().getAnalysisStatusCanceled());
statusesToExclude.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.canceled"));
query.setParameterList("param3", statusesToExclude);
anal = query.uniqueResult();

Expand Down Expand Up @@ -939,7 +951,7 @@ public List<Analysis> getMaxRevisionParentTestAnalysesBySample(SampleItem sample
Query<Analysis> query = entityManager.unwrap(Session.class).createQuery(sql, Analysis.class);
query.setParameter("param", sampleItem.getId());
List<String> statusesToExclude = new ArrayList<>();
statusesToExclude.add(SystemConfiguration.getInstance().getAnalysisStatusCanceled());
statusesToExclude.add(ConfigurationProperties.getInstance().getPropertyValue("analysis.status.canceled"));
query.setParameterList("param2", statusesToExclude);
list = query.list();
} catch (RuntimeException e) {
Expand Down
21 changes: 11 additions & 10 deletions src/main/java/org/openelisglobal/analysis/valueholder/Analysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
import java.util.UUID;
import org.apache.commons.validator.GenericValidator;
import org.openelisglobal.analysis.service.AnalysisServiceImpl;
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;
Expand Down Expand Up @@ -166,7 +167,7 @@ public String getCompletedDateForDisplay() {
public void setCompletedDateForDisplay(String completedDateForDisplay) {
this.completedDateForDisplay = completedDateForDisplay;

String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
completedDate = DateUtil.convertStringDateToSqlDate(this.completedDateForDisplay, locale);
}

Expand Down Expand Up @@ -194,7 +195,7 @@ public String getStartedDateForDisplay() {
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);
startedDate = DateUtil.convertStringDateToSqlDate(this.startedDateForDisplay, locale);
}

Expand Down Expand Up @@ -230,7 +231,7 @@ public String getPrintedDateForDisplay() {
public void setPrintedDateForDisplay(String printedDateForDisplay) {
this.printedDateForDisplay = printedDateForDisplay;
// also update the java.sql.Date
String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
printedDate = DateUtil.convertStringDateToSqlDate(this.printedDateForDisplay, locale);
}

Expand All @@ -250,7 +251,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(this.releasedDateForDisplay, locale);
}

Expand Down Expand Up @@ -278,7 +279,7 @@ public String getSoNotifyReceivedDateForDisplay() {
public void setSoNotifyReceivedDateForDisplay(String soNotifyReceivedDateForDisplay) {
this.soNotifyReceivedDateForDisplay = soNotifyReceivedDateForDisplay;
// also update the java.sql.Date
String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
soNotifyReceivedDate = DateUtil.convertStringDateToSqlDate(this.soNotifyReceivedDateForDisplay, locale);
}

Expand All @@ -298,7 +299,7 @@ public String getSoNotifySendDateForDisplay() {
public void setSoNotifySendDateForDisplay(String soNotifySendDateForDisplay) {
this.soNotifySendDateForDisplay = soNotifySendDateForDisplay;
// also update the java.sql.Date
String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
soNotifySendDate = DateUtil.convertStringDateToSqlDate(this.soNotifySendDateForDisplay, locale);
}

Expand All @@ -318,7 +319,7 @@ public String getSoSendDateForDisplay() {
public void setSoSendDateForDisplay(String soSendDateForDisplay) {
this.soSendDateForDisplay = soSendDateForDisplay;
// also update the java.sql.Date
String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
soSendDate = DateUtil.convertStringDateToSqlDate(this.soSendDateForDisplay, locale);
}

Expand Down Expand Up @@ -346,7 +347,7 @@ public String getSoSendEntryDateForDisplay() {
public void setSoSendEntryDateForDisplay(String soSendEntryDateForDisplay) {
this.soSendEntryDateForDisplay = soSendEntryDateForDisplay;
// also update the java.sql.Date
String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
soSendEntryDate = DateUtil.convertStringDateToSqlDate(this.soSendEntryDateForDisplay, locale);
}

Expand All @@ -366,7 +367,7 @@ public String getSoSendReadyDateForDisplay() {
public void setSoSendReadyDateForDisplay(String soSendReadyDateForDisplay) {
this.soSendReadyDateForDisplay = soSendReadyDateForDisplay;
// also update the java.sql.Date
String locale = SystemConfiguration.getInstance().getDefaultLocale().toString();
String locale = ConfigurationProperties.getInstance().getPropertyValue(Property.DEFAULT_LANG_LOCALE);
soSendReadyDate = DateUtil.convertStringDateToSqlDate(this.soSendReadyDateForDisplay, locale);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@

import java.sql.Date;
import org.openelisglobal.analysis.valueholder.Analysis;
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;
Expand Down Expand Up @@ -120,7 +121,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);
this.completedDate = DateUtil.convertStringDateToSqlDate(completedDateForDisplay, locale);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import java.sql.Date;
import org.openelisglobal.action.valueholder.Action;
import org.openelisglobal.analysisqaevent.valueholder.AnalysisQaEvent;
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;
Expand Down Expand Up @@ -124,7 +125,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);
}

Expand Down
Loading

0 comments on commit e2b289a

Please sign in to comment.