Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down
2 changes: 1 addition & 1 deletion EHR_App/test/src/org/labkey/test/tests/EHR_AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected File getStudyPolicyXML()
@BeforeClass
public static void setupProject() throws Exception
{
EHR_AppTest init = (EHR_AppTest) getCurrentTest();
EHR_AppTest init = getCurrentTest();
init.doSetup();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@
*/
package org.labkey.ehr_compliancedb.notification;

import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.Container;
import org.apache.commons.lang3.time.DateUtils;
import org.labkey.api.module.ModuleLoader;
import org.labkey.api.module.Module;
import org.labkey.api.data.CompareType;
import org.labkey.api.data.Results;
import org.labkey.api.data.ColumnInfo;
import org.labkey.api.data.ResultsImpl;
import org.labkey.api.data.Selector;
import org.labkey.api.data.SimpleFilter;
import org.labkey.api.data.Sort;
Expand All @@ -36,20 +31,15 @@
import org.labkey.api.query.UserSchema;
import org.labkey.api.ldk.notification.AbstractNotification;
import org.labkey.api.util.DateUtil;
import org.labkey.ehr_compliancedb.EHR_ComplianceDBModule;
import org.labkey.ehr_compliancedb.EHR_ComplianceDBUserSchema;


import java.util.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

//Added 3-29-2016 Blasa

Expand Down Expand Up @@ -153,12 +143,12 @@ private void EmployeeComplianceNotification(Container c, User u, final StringBui
msg.append("<tr style='font-weight: bold;'><td>Employee ID</td><td>First Name</td><td>Last Name</td><td>Category</td><td>Unit</td><td>Supervisor</td><td>Location</td></tr>\n");


ts.forEach(new Selector.ForEachBlock<ResultSet>()
ts.forEach(new Selector.ForEachBlock<>()
{
@Override
public void exec(ResultSet rs) throws SQLException
{
msg.append("<tr><td>" + (rs.getString("employeeid") == null ? "" : rs.getString("employeeid")) + "</td><td>" + rs.getString("firstName") + "</td><td>" + rs.getString("lastName") + "</td><td>" + rs.getString("category") + "</td><td>" + rs.getString("unit") + "</td><td>" + rs.getString("supervisor") + "</td><td>" + rs.getString("location")+ "</td></tr>\n");
msg.append("<tr><td>" + (rs.getString("employeeid") == null ? "" : rs.getString("employeeid")) + "</td><td>" + rs.getString("firstName") + "</td><td>" + rs.getString("lastName") + "</td><td>" + rs.getString("category") + "</td><td>" + rs.getString("unit") + "</td><td>" + rs.getString("supervisor") + "</td><td>" + rs.getString("location") + "</td></tr>\n");

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ public EHR_PurchasingController()
}

@RequiresPermission(ReadPermission.class)
public class BeginAction extends SimpleViewAction
public static class BeginAction extends SimpleViewAction<Object>
{
@Override
public ModelAndView getView(Object o, BindException errors)
{
return new JspView("/org/labkey/ehr_purchasing/view/hello.jsp");
return new JspView<>("/org/labkey/ehr_purchasing/view/hello.jsp");
}

@Override
public void addNavTrail(NavTree root) { }
}
}
5 changes: 4 additions & 1 deletion EHR_SM/src/org/labkey/ehr_sm/EHR_SMController.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ public EHR_SMController()
}

@RequiresPermission(ReadPermission.class)
public class BeginAction extends SimpleViewAction
public static class BeginAction extends SimpleViewAction<Object>
{
@Override
public ModelAndView getView(Object o, BindException errors)
{
JspView<Void> view = new JspView<>("/org/labkey/ehr_sm/view/hello.jsp");
view.setTitle("EHR Sample Manager");
return view;
}

@Override
public void addNavTrail(NavTree root) { }
}

Expand Down Expand Up @@ -100,6 +102,7 @@ public void setSelectedAnimalSampleTypes(String[] selectedAnimalSampleTypes)
@RequiresPermission(AdminPermission.class)
public class AdminAction extends FormViewAction<AdminForm>
{
@Override
public void addNavTrail(NavTree root) { }

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected void doCleanup(boolean afterTest) throws TestTimeoutException
@BeforeClass
public static void setupProject()
{
EHR_SMTest init = (EHR_SMTest)getCurrentTest();
EHR_SMTest init = getCurrentTest();

init.doSetup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public JSONObject getMetadata(ViewContext ctx, ExpProtocol protocol)
return meta;
}

private class Parser extends DefaultAssayParser
private static class Parser extends DefaultAssayParser
{
private final Double CYCLE_LIMIT = 45.0;
private static final String TASK_FIELD = "Task";
Expand All @@ -178,7 +178,7 @@ public Parser(AssayImportMethod method, Container c, User u, int assayId)
@Override
public Pair<ExpExperiment, ExpRun> saveBatch(JSONObject json, File file, String fileName, ViewContext ctx) throws BatchValidationException
{
Integer templateId = json.getInt("TemplateId");
int templateId = json.getInt("TemplateId");

Pair<ExpExperiment, ExpRun> result = super.saveBatch(json, file, fileName, ctx);

Expand Down Expand Up @@ -217,7 +217,7 @@ protected String readRawFile(ImportContext context) throws BatchValidationExcept

if (!inResults)
{
if (row.size() == 0)
if (row.isEmpty())
continue;

if (row.get(0).equals("Detector Name"))
Expand All @@ -229,7 +229,7 @@ protected String readRawFile(ImportContext context) throws BatchValidationExcept
if (inDetectors)
{
String detector = row.get(0);
Map<String, Double> map = new HashMap<String, Double>();
Map<String, Double> map = new HashMap<>();
map.put("slope", Double.parseDouble(row.get(1)));
map.put("intercept", Double.parseDouble(row.get(2)));
map.put("rSquared", Double.parseDouble(row.get(3)));
Expand Down Expand Up @@ -262,7 +262,7 @@ else if (row.get(0).startsWith("Document Name:"))
}
else
{
out.writeNext(row.toArray(new String[row.size()]));
out.writeNext(row.toArray(new String[0]));
}
}

Expand All @@ -284,7 +284,7 @@ else if (row.get(0).startsWith("Document Name:"))
@Override
protected List<Map<String, Object>> processRowsFromFile(List<Map<String, Object>> rows, ImportContext context) throws BatchValidationException
{
List<Map<String, Object>> newRows = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> newRows = new ArrayList<>();
ParserErrors errors = context.getErrors();

//add slope to run info
Expand All @@ -308,7 +308,7 @@ protected List<Map<String, Object>> processRowsFromFile(List<Map<String, Object>
{
rowIdx++;
Map<String, Object> row = rowsIter.next();
Map<String, Object> map = new CaseInsensitiveHashMap<Object>(row);
Map<String, Object> map = new CaseInsensitiveHashMap<>(row);

if (row.size() != 9)
{
Expand Down Expand Up @@ -444,7 +444,7 @@ private void calculateViralLoad(Map<String, Object> map, Double limitOfDetection
{
Map<String, Double> detectorInfo = _detectorMap.get(map.get(DETECTOR_FIELD));
Double ct = map.get("cp") == null ? null : Double.parseDouble(map.get("cp").toString());
Double sampleVol = Double.parseDouble(String.valueOf(map.get("sampleVol")));
double sampleVol = Double.parseDouble(String.valueOf(map.get("sampleVol")));
Double intercept = detectorInfo.get("intercept");
Double slope = detectorInfo.get("slope");
Double volPerRxn = Double.parseDouble(String.valueOf(map.get("volPerRxn")));
Expand All @@ -463,14 +463,14 @@ private void calculateViralLoad(Map<String, Object> map, Double limitOfDetection

private void calculateViralLoads(List<Map<String, Object>> rows)
{
Map<String, List<Map<String, Object>>> rowMap = new HashMap<String, List<Map<String, Object>>>();
Map<String, List<Map<String, Object>>> rowMap = new HashMap<>();
Double lowestStd = 0.0;
for (Map<String, Object> row : rows)
{
String key = (String)row.get(NAME_FIELD);
List<Map<String, Object>> list = rowMap.get(key);
if (list == null)
list = new ArrayList<Map<String, Object>>();
list = new ArrayList<>();

if (TYPE.Standard.getTemplateText().equals(row.get(CATEGORY_FIELD)))
{
Expand Down Expand Up @@ -505,7 +505,7 @@ private void calculateViralLoads(List<Map<String, Object>> rows)

avgCopies = avgCopies / list.size();
Double stdDev = new StandardDeviation().evaluate(values);
Double cv = stdDev / avgCopies;
double cv = stdDev / avgCopies;

//NOTE: at some point I should make this configurable
//flag any record with %CV > 66, but only if at least 1 replicate has copies/rxn above limitOfDetection
Expand Down Expand Up @@ -573,14 +573,14 @@ public void doGenerateTemplate(JSONObject json, HttpServletRequest request, Http
response.setHeader("Pragma", "private");
response.setHeader("Cache-Control", "private");

Map<Integer, String[]> rowMap = new HashMap<Integer, String[]>();
Map<Integer, String[]> rowMap = new HashMap<>();

int rowIdx = 0;
for (JSONObject row : results)
{
rowIdx++;

List<String> fields = new ArrayList<String>();
List<String> fields = new ArrayList<>();

//build the row
Integer wellNum = (Integer)wellMap.get(row.getString("well"));
Expand All @@ -594,13 +594,13 @@ public void doGenerateTemplate(JSONObject json, HttpServletRequest request, Http
fields.add(type.getTemplateText());
fields.add(TYPE.getQuantity(type, row.getString(SUBJECT_FIELD)));

rowMap.put(wellNum, fields.toArray(new String[fields.size()]));
rowMap.put(wellNum, fields.toArray(new String[0]));
}

if (errors.hasErrors())
throw errors;

List<String[]> rows = new ArrayList<String[]>();
List<String[]> rows = new ArrayList<>();
rows.add(new String[]{"*** SDS Setup File Version", "3"});
rows.add(new String[]{"*** Output Plate Size", "96"});
rows.add(new String[]{"*** Output Plate ID", json.getString("templateName") + ".sds"});
Expand Down Expand Up @@ -642,21 +642,21 @@ public void doGenerateTemplate(JSONObject json, HttpServletRequest request, Http

private Map<String, Map<String, String>> getDetectorsForResults(List<JSONObject> results)
{
final Map<String, Map<String, String>> ret = new HashMap<String, Map<String, String>>();
Set<String> distinctAssays = new HashSet<String>();
final Map<String, Map<String, String>> ret = new HashMap<>();
Set<String> distinctAssays = new HashSet<>();
for (JSONObject row : results)
{
distinctAssays.add(row.getString(ASSAYNAME_FIELD));
}

TableInfo table = Viral_Load_AssaySchema.getInstance().getSchema().getTable(Viral_Load_AssaySchema.TABLE_ABI7500_DETECTORS);
TableSelector ts = new TableSelector(table, new SimpleFilter(FieldKey.fromString("assayName"), distinctAssays, CompareType.IN), null);
ts.forEach(new Selector.ForEachBlock<ResultSet>()
ts.forEach(new Selector.ForEachBlock<>()
{
@Override
public void exec(ResultSet object) throws SQLException
{
Map<String, String> row = new HashMap<String, String>();
Map<String, String> row = new HashMap<>();
row.put("detector", object.getString("detector"));
row.put("reporter", object.getString("reporter"));
row.put("quencher", object.getString("quencher"));
Expand All @@ -673,8 +673,8 @@ public void validateTemplate(User u, Container c, ExpProtocol protocol, @Nullabl
//ensure each subject/date has at least 2 neg controls
JSONObject resultDefaults = json.optJSONObject("Results");
JSONArray rawResults = json.getJSONArray("ResultRows");
List<JSONObject> results = new ArrayList<JSONObject>();
Set<String> distinctWells = new HashSet<String>();
List<JSONObject> results = new ArrayList<>();
Set<String> distinctWells = new HashSet<>();
Map<Object, Object> wellMap = getWellMap96("well_96", "addressbyrow_96");

String[] requiredFields = new String[]{"well", SUBJECT_FIELD, CATEGORY_FIELD, ASSAYNAME_FIELD};
Expand Down Expand Up @@ -710,7 +710,7 @@ public void validateTemplate(User u, Container c, ExpProtocol protocol, @Nullabl
if (missingRequired)
continue;

TYPE type = null;
TYPE type;
try
{
type = TYPE.getByDatabaseCategoryValue(row.getString(CATEGORY_FIELD));
Expand Down Expand Up @@ -782,7 +782,7 @@ public void validateTemplate(User u, Container c, ExpProtocol protocol, @Nullabl
}

Map<String, Map<String, String>> detectorRows = getDetectorsForResults(results);
if (detectorRows.size() == 0)
if (detectorRows.isEmpty())
{
errors.addRowError(new ValidationException("No detectors were found for these samples."));
throw errors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ protected void calculateViralLoadForRoche(Map<String, Object> map)
map.put("sampleVol", 1.0);

//This is the size (ml or mg) of the source material (plasma/serum/urine/etc.)
Double sampleVol = Double.parseDouble(map.get("sampleVol").toString());
double sampleVol = Double.parseDouble(map.get("sampleVol").toString());

Double viralLoad = 0.0;
Double dilutionFactor = 0.0;
double viralLoad = 0.0;
double dilutionFactor = 0.0;
if (copiesPerRxn != null && sampleVol > 0)
{
dilutionFactor = (1.0 / sampleVol) * (eluateVol / volPerRxn);
Expand All @@ -417,8 +417,8 @@ protected void calculateViralLoadForRoche(Map<String, Object> map)
}

protected class Parser extends DefaultAssayParser {
private String HAS_RESULT = "__hasResult__";
private int _assayId;
private final String HAS_RESULT = "__hasResult__";
private final int _assayId;
final String[] lookup = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.".split("");
//The expected number of columns in the import data
private int _expectedColumnCount = Integer.MAX_VALUE;
Expand All @@ -444,6 +444,7 @@ public Pair<ExpExperiment, ExpRun> saveBatch(JSONObject json, File file, String
}

//Needs to be overridden within the Parser class of each ImportMethod that extends AbstractWNPRCImportMethod
@Override
protected TabLoader getTabLoader(String contents) throws IOException {
return null;
}
Expand Down Expand Up @@ -531,6 +532,7 @@ protected List<Map<String, Object>> processRowsFromFile(List<Map<String, Object>
return newRows;
}

@Override
protected void ensureTemplateRowsHaveResults(Map<String, Map<String, Object>> templateRows, ImportContext context) throws BatchValidationException {
for (String key : templateRows.keySet()) {
Map<String, Object> row = templateRows.get(key);
Expand Down Expand Up @@ -563,7 +565,7 @@ private String uncompressUUID(String compressObjectId) {
else if (hexString.length() == 2) {
hexString = "0" + hexString;
}
else if (hexString.length() == 0) {
else if (hexString.isEmpty()) {
hexString = "000" + hexString;
}

Expand All @@ -577,19 +579,17 @@ else if (hexString.length() == 0) {
}
char[] objectId = base16Duples.toString().toCharArray();

StringBuilder returnObjectId = new StringBuilder();

returnObjectId.append(objectId, 0, 8);
returnObjectId.append("-");
returnObjectId.append(objectId, 8, 4);
returnObjectId.append("-");
returnObjectId.append(objectId, 12, 4);
returnObjectId.append("-");
returnObjectId.append(objectId, 16, 4);
returnObjectId.append("-");
returnObjectId.append(objectId, 20, 12);

return returnObjectId.toString();
String returnObjectId = String.valueOf(objectId, 0, 8) +
"-" +
String.valueOf(objectId, 8, 4) +
"-" +
String.valueOf(objectId, 12, 4) +
"-" +
String.valueOf(objectId, 16, 4) +
"-" +
String.valueOf(objectId, 20, 12);

return returnObjectId;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected void calculateViralLoadForRoche(Map<String, Object> map)
if (!map.containsKey("sampleVol"))
map.put("sampleVol", 1.0);

Double sampleVol = Double.parseDouble(map.get("sampleVol").toString());
double sampleVol = Double.parseDouble(map.get("sampleVol").toString());

double viralLoad;
if (copiesPerRxn != null)
Expand Down
Loading