diff --git a/hdrl/src/org/labkey/hdrl/HDRLContainerListener.java b/hdrl/src/org/labkey/hdrl/HDRLContainerListener.java index 7c3bed6a..3bdef70c 100644 --- a/hdrl/src/org/labkey/hdrl/HDRLContainerListener.java +++ b/hdrl/src/org/labkey/hdrl/HDRLContainerListener.java @@ -28,7 +28,6 @@ import org.labkey.api.security.User; import org.labkey.api.util.ContainerUtil; import org.labkey.hdrl.query.LabWareQuerySchema; -import org.labkey.remoteapi.assay.Data; import java.util.Collections; import java.util.Collection; diff --git a/hdrl/src/org/labkey/hdrl/HDRLController.java b/hdrl/src/org/labkey/hdrl/HDRLController.java index 6a8b8814..29e53218 100644 --- a/hdrl/src/org/labkey/hdrl/HDRLController.java +++ b/hdrl/src/org/labkey/hdrl/HDRLController.java @@ -132,7 +132,7 @@ public void addNavTrail(NavTree root) @RequiresPermission(ReadPermission.class) - public class RequestDetailsAction extends SimpleViewAction + public static class RequestDetailsAction extends SimpleViewAction { @Override public ModelAndView getView(Object o, BindException errors) @@ -141,7 +141,7 @@ public ModelAndView getView(Object o, BindException errors) if (requestId != null) { InboundRequestBean bean = HDRLManager.get().getInboundRequest(getUser(), getContainer(), Integer.parseInt(requestId)); - JspView jsp = new JspView("/org/labkey/hdrl/view/requestDetails.jsp", bean); + JspView jsp = new JspView<>("/org/labkey/hdrl/view/requestDetails.jsp", bean); jsp.setTitle("Test Request"); UserSchema schema = QueryService.get().getUserSchema(getUser(), getContainer(), HDRLQuerySchema.NAME); @@ -166,7 +166,7 @@ public void addNavTrail(NavTree root) } @RequiresPermission(InsertPermission.class) - public class EditRequestAction extends SimpleViewAction + public static class EditRequestAction extends SimpleViewAction { private String _navLabel = "Create a new Test Request"; @@ -259,7 +259,7 @@ public void setTestTypeId(Integer testTypeId) } @RequiresPermission(ReadPermission.class) - public class VerifySpecimenAction extends ReadOnlyApiAction + public static class VerifySpecimenAction extends ReadOnlyApiAction { @Override public Object execute(VerifyForm form, BindException errors) @@ -310,7 +310,7 @@ public static class VerifyForm extends SimpleApiJsonForm @RequiresPermission(ReadPermission.class) - public class DownloadClinicalReportAction extends ExportAction + public static class DownloadClinicalReportAction extends ExportAction { @Override public void export(SpecimenForm form, HttpServletResponse response, BindException errors) throws Exception @@ -361,7 +361,7 @@ public void setSpecimenId(Integer specimenId) } @RequiresPermission(ReadPermission.class) - public class DownloadSpecimenTemplateAction extends ExportAction + public static class DownloadSpecimenTemplateAction extends ExportAction { @Override public void export(Object o, HttpServletResponse response, BindException errors) @@ -385,7 +385,7 @@ public void export(Object o, HttpServletResponse response, BindException errors) } @RequiresPermission(ReadPermission.class) - public class PrintPackingListAction extends SimpleViewAction + public static class PrintPackingListAction extends SimpleViewAction { @Override public ModelAndView getView(PackingListBean packingListBean, BindException errors) @@ -483,7 +483,7 @@ public void setShippingNumber(String shippingNumber) @AdminConsoleAction @RequiresPermission(AdminPermission.class) - public class HDRLSensitiveDataAdminAction extends FormViewAction + public static class HDRLSensitiveDataAdminAction extends FormViewAction { @Override public void validateCommand(SensitiveDataForm target, Errors errors) @@ -537,7 +537,7 @@ public void setTimeWindowInDays(int timeWindowInDays) @RequiresPermission(AdminPermission.class) @Marshal(Marshaller.Jackson) - public class AddLabWareOutboundRequestAction extends MutatingApiAction + public static class AddLabWareOutboundRequestAction extends MutatingApiAction { @Override public Object execute(LabWareOutboundRequestForm form, BindException errors) @@ -633,7 +633,7 @@ public void setDateModified(Date dateModified) @RequiresPermission(AdminPermission.class) @Marshal(Marshaller.Jackson) - public class AddLabWareOutboundSpecimenAction extends MutatingApiAction + public static class AddLabWareOutboundSpecimenAction extends MutatingApiAction { @Override public Object execute(LabWareOutboundSpecimenForm form, BindException errors) throws Exception diff --git a/hdrl/src/org/labkey/hdrl/HDRLFolderType.java b/hdrl/src/org/labkey/hdrl/HDRLFolderType.java index cd77710b..51daed65 100644 --- a/hdrl/src/org/labkey/hdrl/HDRLFolderType.java +++ b/hdrl/src/org/labkey/hdrl/HDRLFolderType.java @@ -15,7 +15,6 @@ */ package org.labkey.hdrl; -import org.labkey.api.module.Module; import org.labkey.api.module.MultiPortalFolderType; import org.labkey.api.view.Portal; diff --git a/hdrl/src/org/labkey/hdrl/HDRLMaintenanceTask.java b/hdrl/src/org/labkey/hdrl/HDRLMaintenanceTask.java index 19c7abf1..4a7b2a2e 100644 --- a/hdrl/src/org/labkey/hdrl/HDRLMaintenanceTask.java +++ b/hdrl/src/org/labkey/hdrl/HDRLMaintenanceTask.java @@ -16,7 +16,6 @@ package org.labkey.hdrl; import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; import org.labkey.api.data.DbSchema; import org.labkey.api.data.DbScope; import org.labkey.api.data.SQLFragment; diff --git a/hdrl/src/org/labkey/hdrl/query/HDRLQuerySchema.java b/hdrl/src/org/labkey/hdrl/query/HDRLQuerySchema.java index 4bedccf2..ee58ce3c 100644 --- a/hdrl/src/org/labkey/hdrl/query/HDRLQuerySchema.java +++ b/hdrl/src/org/labkey/hdrl/query/HDRLQuerySchema.java @@ -79,7 +79,7 @@ public class HDRLQuerySchema extends SimpleUserSchema public static final String TABLE_LABWARE_OUTBOUND_RESULTS = "LabwareOutboundRequests"; public static final String TABLE_LABWARE_OUTBOUND_SPECIMENS = "LabwareOutboundSpecimens"; - public static final String COL_REQUEST_STATUS_ID = "RequestStatusId";; + public static final String COL_REQUEST_STATUS_ID = "RequestStatusId"; public static final String COL_INBOUND_REQUEST_ID = "InboundRequestId"; public static final String COL_ARCHIVED_REQUEST_COUNT = "ArchivedRequestCount"; diff --git a/hdrl/src/org/labkey/hdrl/query/InboundRequestTable.java b/hdrl/src/org/labkey/hdrl/query/InboundRequestTable.java index 26c0f261..0690cbb6 100644 --- a/hdrl/src/org/labkey/hdrl/query/InboundRequestTable.java +++ b/hdrl/src/org/labkey/hdrl/query/InboundRequestTable.java @@ -17,7 +17,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.ContainerForeignKey; import org.labkey.api.data.DatabaseTableType; diff --git a/hdrl/src/org/labkey/hdrl/query/InboundRequestUpdateService.java b/hdrl/src/org/labkey/hdrl/query/InboundRequestUpdateService.java index 8f2971d3..d63115b5 100644 --- a/hdrl/src/org/labkey/hdrl/query/InboundRequestUpdateService.java +++ b/hdrl/src/org/labkey/hdrl/query/InboundRequestUpdateService.java @@ -107,16 +107,16 @@ public static void validateUniqueness(Integer requestId) throws QueryUpdateServi // check that there are no duplicate barcodes List duplicates = findDuplicates(requestId, "CustomerBarcode"); StringBuilder message = new StringBuilder(); - if (duplicates.size() > 0) + if (!duplicates.isEmpty()) { message.append("Request has specimens with duplicate fields: Customer Barcode - ").append(StringUtils.join(duplicates, ", ")); } // check that all existing DODId in the specimens in this request are unique duplicates = findDuplicates(requestId, "DoDId"); - if (duplicates.size() > 0) + if (!duplicates.isEmpty()) { - if (message.length() == 0) + if (message.isEmpty()) message.append("Request has specimens with duplicate fields: "); else message.append("; "); @@ -124,16 +124,16 @@ public static void validateUniqueness(Integer requestId) throws QueryUpdateServi } // check that all the existing SSN + FMP pairs in this request are unique duplicates = findDuplicates(requestId, "SSN, FMPId"); - if (duplicates.size() > 0) + if (!duplicates.isEmpty()) { - if (message.length() == 0) + if (message.isEmpty()) message.append("Request has specimens with duplicate fields: "); else message.append("; "); message.append("SSN + FMP - ").append(StringUtils.join(duplicates, ", ")); } - if (message.length() > 0) + if (!message.isEmpty()) throw new QueryUpdateServiceException(message.toString()); } diff --git a/hdrl/src/org/labkey/hdrl/query/InboundSpecimenUpdateService.java b/hdrl/src/org/labkey/hdrl/query/InboundSpecimenUpdateService.java index f7f55ff2..7b494203 100644 --- a/hdrl/src/org/labkey/hdrl/query/InboundSpecimenUpdateService.java +++ b/hdrl/src/org/labkey/hdrl/query/InboundSpecimenUpdateService.java @@ -125,8 +125,8 @@ public static void validate(Map row) throws ValidationException calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); Date today = calendar.getTime(); - List errors = new ArrayList(); - List missingFields = new ArrayList(); + List errors = new ArrayList<>(); + List missingFields = new ArrayList<>(); if (row.get("FMPId") == null) missingFields.add("FMP"); if (row.get("DrawDate") == null) @@ -151,30 +151,34 @@ public static void validate(Map row) throws ValidationException } } } - if (row.get("BirthDate") != null) + Object birthDateObj = row.get("BirthDate"); + if (birthDateObj != null) { Date birthDate = null; - if (row.get("BirthDate") instanceof Date) - birthDate = (Date) row.get("BirthDate"); + if (birthDateObj instanceof Date d) + birthDate = d; else { try { birthDate = dateFormat.parse((String) row.get("BirthDate")); - if (birthDate.after(today)) - { - errors.add("Birth date cannot be in the future"); - } - else if ((drawDate != null) && (drawDate.before(birthDate))) - { - errors.add("Draw date cannot be before birth date"); - } } catch (ParseException e) { errors.add("Invalid birth date format"); } } + if (birthDate != null) + { + if (birthDate.after(today)) + { + errors.add("Birth date cannot be in the future"); + } + else if ((drawDate != null) && (drawDate.before(birthDate))) + { + errors.add("Draw date cannot be before birth date"); + } + } } if (row.get("SSN") == null || StringUtils.isEmpty(String.valueOf(row.get("SSN")))) missingFields.add("SSN"); diff --git a/hdrl/src/org/labkey/hdrl/query/ResultTable.java b/hdrl/src/org/labkey/hdrl/query/ResultTable.java index ccc64a61..53bee293 100644 --- a/hdrl/src/org/labkey/hdrl/query/ResultTable.java +++ b/hdrl/src/org/labkey/hdrl/query/ResultTable.java @@ -30,7 +30,6 @@ import org.labkey.api.security.UserPrincipal; import org.labkey.api.security.permissions.Permission; -import java.sql.SQLException; import java.util.Map; /** diff --git a/hdrl/test/src/org/labkey/test/tests/HDRLTest.java b/hdrl/test/src/org/labkey/test/tests/HDRLTest.java index 04536284..7d710db6 100644 --- a/hdrl/test/src/org/labkey/test/tests/HDRLTest.java +++ b/hdrl/test/src/org/labkey/test/tests/HDRLTest.java @@ -66,8 +66,8 @@ public class HDRLTest extends BaseWebDriverTest implements PostgresOnlyTest public static final Locator.XPathLocator enabledSave = Locator.xpath("//a[not(contains(normalize-space(@class), 'x4-btn-disable'))]//span[text()='" + SAVE_BUTTON_TEXT + "']"); public static final Locator.XPathLocator enabledPrintPackingList = Locator.xpath("//a[not(contains(normalize-space(@class), 'x4-btn-disable'))]//span[text()='" + PRINT_PACKING_LIST_TEXT + "']"); - private static int CARRIER_COLUMN_INDEX = 2; - private static int STATUS_COLUMN_INDEX = 13; + private static final int CARRIER_COLUMN_INDEX = 2; + private static final int STATUS_COLUMN_INDEX = 13; @Override protected String getProjectName() @@ -78,7 +78,7 @@ protected String getProjectName() @BeforeClass public static void initProject() { - HDRLTest init = (HDRLTest)getCurrentTest(); + HDRLTest init = getCurrentTest(); init.setupFolder(); } @@ -150,7 +150,7 @@ public void testRetrievalOfResultsAndArchiving() throws Exception clickButton(SUBMIT_BUTTON_TEXT); DataRegionTable drt = new DataRegionTable("query", this); int idx = drt.getRowIndex("ShippingNumber", "testRetrievalOfResults"); - assertNotEquals(idx, -1); + assertNotEquals(-1, idx); String requestId = drt.getDataAsText(idx, "RequestId"); Map result = new HashMap<>(); @@ -236,7 +236,7 @@ public void testRetrievalOfResultsAndArchiving() throws Exception click(Locator.linkContainingText("View test requests")); drt = new DataRegionTable("query", this); idx = drt.getRowIndex("RequestId", requestId); - assertNotEquals(idx, -1); + assertNotEquals(-1, idx); log("view test results"); assertEquals("VIEW", drt.getDataAsText(idx, 0)); clickAndWait(drt.link(idx, 0)); @@ -395,7 +395,7 @@ public void testFileUploadAndSubmit() DataRegionTable drt = new DataRegionTable("query", this); int idx = drt.getRowIndex("ShippingCarrier", "FedEx"); - assertNotEquals(idx, -1); + assertNotEquals(-1, idx); clickAndWait(drt.link(idx, 0)); log("submitting an existing request"); waitForElement(Locator.tagContainingText("div", "222-33-4444")); @@ -404,7 +404,7 @@ public void testFileUploadAndSubmit() drt = new DataRegionTable("query", this); idx = drt.getRowIndex("ShippingCarrier", "FedEx"); - assertNotEquals(idx, -1); + assertNotEquals(-1, idx); Assert.assertFalse(drt.getDataAsText(idx, "Submitted By").trim().isEmpty()); // "submitted by" field should be filled in Assert.assertFalse(drt.getDataAsText(idx, "Submitted").trim().isEmpty()); // submitted date should be filled in @@ -423,7 +423,7 @@ public void testFileUploadAndSubmit() clickAndWait(Locator.linkContainingText("View test requests")); drt = new DataRegionTable("query", this); idx = drt.getRowIndex("ShippingCarrier", "FedEx"); - assertNotEquals(idx, -1); + assertNotEquals(-1, idx); log("ensure submitted requests are still editable by admins"); assertEquals("VIEW", drt.getDataAsText(idx, 0)); clickAndWait(drt.link(idx, 0)); @@ -454,7 +454,7 @@ public void testEditSubmittedRequest() log("Edit the submitted request as admin"); DataRegionTable drt = new DataRegionTable("query", this); int idx = drt.getRowIndex("ShippingNumber", "testEditSubmittedRequest"); - assertNotEquals(idx, -1); + assertNotEquals(-1, idx); assertEquals("Submitted", drt.getDataAsText(idx, STATUS_COLUMN_INDEX)); String submittedDate = drt.getDataAsText(idx, 6).trim(); @@ -476,7 +476,7 @@ public void testEditSubmittedRequest() log("Test that not saving request does not change anything"); clickButton("Cancel", 0); // takes you back to the view test requests page idx = drt.getRowIndex("ShippingNumber", "testEditSubmittedRequest"); - assertNotEquals(idx, -1); + assertNotEquals(-1, idx); assertEquals("Submitted", drt.getDataAsText(idx, STATUS_COLUMN_INDEX)); assertNotEquals("DHL", drt.getDataAsText(idx, CARRIER_COLUMN_INDEX)); assertEquals("EDIT", drt.getDataAsText(idx, 0)); @@ -491,7 +491,7 @@ public void testEditSubmittedRequest() log("Test that saving request does not change the request status"); idx = drt.getRowIndex("ShippingNumber", "testEditSubmittedRequest"); - assertNotEquals(idx, -1); + assertNotEquals(-1, idx); assertEquals("Submitted", drt.getDataAsText(idx, STATUS_COLUMN_INDEX)); assertEquals("DHL", drt.getDataAsText(idx, CARRIER_COLUMN_INDEX)); // submitted date should still be the same @@ -528,7 +528,7 @@ public void testDataDeletion() click(Locator.linkWithText("View test requests")); DataRegionTable drt = new DataRegionTable("query", this); int idx = drt.getRowIndex("ShippingNumber", "testRetrievalOfResults"); - assertNotEquals(idx, -1); + assertNotEquals(-1, idx); String requestId = drt.getDataAsText(idx, "RequestId"); Assert.assertEquals("Archived", drt.getDataAsText(idx, "Status")); List specimenIds = getSpecimenIds(requestId, "hdrl", "InboundSpecimen", "RowId"); @@ -600,7 +600,7 @@ private void verifyDataRegionRows(String tableName, List> ex for (Map expectedRow : expectedRows) { int idx = drt.getRowIndex(key, expectedRow.get(key)); - assertNotEquals(String.format("Didn't find row with %s = %s", key, expectedRow.get(key)), idx, -1); + assertNotEquals(String.format("Didn't find row with %s = %s", key, expectedRow.get(key)), -1, idx); Map actualRow = new HashMap<>(); for (Map.Entry field : expectedRow.entrySet()) diff --git a/ms2extensions/src/org/labkey/ms2extensions/MS2ExtensionsController.java b/ms2extensions/src/org/labkey/ms2extensions/MS2ExtensionsController.java index 1e4aa132..b1278a8e 100644 --- a/ms2extensions/src/org/labkey/ms2extensions/MS2ExtensionsController.java +++ b/ms2extensions/src/org/labkey/ms2extensions/MS2ExtensionsController.java @@ -96,7 +96,7 @@ private static String getPreference(ViewContext viewContext, String preferenceNa } @RequiresPermission(AdminOperationsPermission.class) - public class UpdatePeptideCountsAction extends SimpleViewAction + public static class UpdatePeptideCountsAction extends SimpleViewAction { @Override public ModelAndView getView(Object o, BindException errors) @@ -105,7 +105,7 @@ public ModelAndView getView(Object o, BindException errors) { List warnings = new ArrayList<>(); updatePeptideCounts(warnings, getContainer()); - if (warnings.size() == 0) + if (warnings.isEmpty()) { return new HtmlView(DOM.DIV("Success!")); } @@ -139,7 +139,7 @@ public void addNavTrail(NavTree root) } @RequiresPermission(ReadPermission.class) - public class SetPreferencesAction extends MutatingApiAction + public static class SetPreferencesAction extends MutatingApiAction { @Override public ApiResponse execute(SimpleApiJsonForm simpleApiJsonForm, BindException errors) diff --git a/ms2extensions/src/org/labkey/ms2extensions/PeptideCountPepXmlDataHandler.java b/ms2extensions/src/org/labkey/ms2extensions/PeptideCountPepXmlDataHandler.java index 75f6d32e..d044729a 100644 --- a/ms2extensions/src/org/labkey/ms2extensions/PeptideCountPepXmlDataHandler.java +++ b/ms2extensions/src/org/labkey/ms2extensions/PeptideCountPepXmlDataHandler.java @@ -16,7 +16,6 @@ package org.labkey.ms2extensions; import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.Container; import org.labkey.api.exp.ExperimentDataHandler; diff --git a/pepdb/src/org/scharp/atlas/pepdb/PepDBBaseController.java b/pepdb/src/org/scharp/atlas/pepdb/PepDBBaseController.java index 829b57ef..560d5e1f 100644 --- a/pepdb/src/org/scharp/atlas/pepdb/PepDBBaseController.java +++ b/pepdb/src/org/scharp/atlas/pepdb/PepDBBaseController.java @@ -215,7 +215,7 @@ && validateInteger(getAAStart().trim()) > validateInteger(getAAEnd().trim())) { if (StringUtils.trimToNull(qValue) == null) errors.reject(null, "The Peptide Id range must be entered."); - if (qValue != null && qValue.length() > 0) + if (qValue != null && !qValue.isEmpty()) { if (!(qValue.matches("\\d+-\\d+"))) { @@ -423,7 +423,7 @@ public boolean validate(Errors errors, AttachmentFile file) throws Exception errors.reject(null, "File name must end with in .txt.\nFile should be tab delimited text file and the number of field vary depending on file type."); } } - if (getActionType() == null || getActionType().length() == 0) + if (getActionType() == null || getActionType().isEmpty()) errors.reject(null, "File Type is required"); if(errors.getErrorCount() > 0) return false; diff --git a/pepdb/src/org/scharp/atlas/pepdb/PepDBManager.java b/pepdb/src/org/scharp/atlas/pepdb/PepDBManager.java index 251e17aa..09d144b6 100644 --- a/pepdb/src/org/scharp/atlas/pepdb/PepDBManager.java +++ b/pepdb/src/org/scharp/atlas/pepdb/PepDBManager.java @@ -34,8 +34,8 @@ public class PepDBManager { - private static Logger log = LogManager.getLogger(PepDBManager.class); - private static PepDBSchema schema = PepDBSchema.getInstance(); + private static final Logger log = LogManager.getLogger(PepDBManager.class); + private static final PepDBSchema schema = PepDBSchema.getInstance(); /** * Static class */ @@ -78,7 +78,6 @@ public static Peptides[] getPeptides() } /** - * @param peptideGroup * @return the number of peptides in a given group */ public static Integer getCount(Integer peptideGroup) @@ -319,7 +318,7 @@ public static ProteinCategory getProCatByID(Integer procatId) public static PeptideGroup getPeptideGroupByName(PeptideGroup pg) { - PeptideGroup [] groups = null; + PeptideGroup [] groups; TableInfo tInfo = schema.getTableInfoPeptideGroups(); SQLFragment sql = new SQLFragment("SELECT * FROM "+tInfo+" WHERE UPPER(peptide_group_name) = ? "); sql.add(pg.getPeptide_group_name().trim().toUpperCase()); diff --git a/pepdb/src/org/scharp/atlas/pepdb/PeptideImporter.java b/pepdb/src/org/scharp/atlas/pepdb/PeptideImporter.java index 24ba9a9b..36344150 100644 --- a/pepdb/src/org/scharp/atlas/pepdb/PeptideImporter.java +++ b/pepdb/src/org/scharp/atlas/pepdb/PeptideImporter.java @@ -84,7 +84,7 @@ public ArrayList getPeptideIdList() throws SQLException { if(peptideIdList == null) { - peptideIdList = new ArrayList(); + peptideIdList = new ArrayList<>(); Peptides[] peptides = PepDBManager.getPeptides(); for(Peptides p: peptides) { @@ -114,12 +114,12 @@ public boolean process(User user, AttachmentFile peptideFile, Errors errors, Lis getOptimalElitopeListMap(); HashMap peptideSequenceMap = PepDBManager.getPeptideSequenceMap(); int lineNo =1; - ArrayList newpeptidesList =new ArrayList(); - HashMap lineMap = new HashMap(); + ArrayList newpeptidesList = new ArrayList<>(); + HashMap lineMap = new HashMap<>(); while((line = br.readLine()) != null) { lineNo++; - if(line.length()>0) + if(!line.isEmpty()) { if(validateLine(line,errors,lineNo)) { @@ -143,7 +143,7 @@ public boolean process(User user, AttachmentFile peptideFile, Errors errors, Lis { if(peptideSequenceMap.containsKey(p.getPeptide_sequence())) { - if(p.getPeptide_id() == null || p.getPeptide_id().toString().length() == 0) + if(p.getPeptide_id() == null || p.getPeptide_id().toString().isEmpty()) p.setPeptide_id(peptideSequenceMap.get(p.getPeptide_sequence()).getPeptide_id()); insertGroups(p,user); resultPeptides.add(p); @@ -175,7 +175,7 @@ public boolean process(User user, AttachmentFile peptideFile, Errors errors, Lis parent.setPeptide_id(p.getPeptide_id()); Parent dbParent = PepDBManager.parentExists(parent); if(dbParent == null) - dbParent = PepDBManager.insertParent(user,parent); + PepDBManager.insertParent(user, parent); if(!par.isParent()) { par.setParent(true); @@ -210,10 +210,10 @@ private boolean validateLine(String line,Errors errors,int lineNo) } if(fields.length < 8 ) errors.reject(null,"Line number : "+lineNo+"must have 8-10 fields.The Peptides File has to be tab delimited and should have atleast 8 fields."); - else if((fields[0] == null || fields[0].length() == 0) || (fields[1] == null || fields[1].length() == 0)|| - (fields[2] == null || fields[2].length() == 0) || (fields[3] == null || fields[3].length() == 0)|| - (fields[4] == null || fields[4].length() == 0) || (fields[5] == null || fields[5].length() == 0)|| - (fields[6] == null || fields[6].length() == 0) || (fields[7] == null || fields[7].length() == 0)) + else if((fields[0] == null || fields[0].isEmpty()) || (fields[1] == null || fields[1].isEmpty())|| + (fields[2] == null || fields[2].isEmpty()) || (fields[3] == null || fields[3].isEmpty())|| + (fields[4] == null || fields[4].isEmpty()) || (fields[5] == null || fields[5].isEmpty())|| + (fields[6] == null || fields[6].isEmpty()) || (fields[7] == null || fields[7].isEmpty())) errors.reject(null,"Line number : "+lineNo+" is missing one of the field values \n" + "'PEPTIDE SEQUENCE','IS CHILD','PROTEIN CATEGORY','PEPTIDE GROUP','ID','SEQUENCE LENGTH',\n" + "'AASTART','AAEND','IN A LIST' and 'HLA RESTRICTION'."); @@ -255,12 +255,12 @@ && validateInteger(fields[7].trim()) < validateInteger(fields[6].trim())) if(!fields[3].trim().toUpperCase().equals("OPTIMAL EPITOPES")) errors.reject(null,"Line number : "+lineNo+" If the peptide is a child then the Peptide Group: "+fields[2].trim().toUpperCase()+ " must be 'OPTIMAL EPITOPES'."); - if(fields[8] == null || fields[8].length() == 0 || !optimalElitopeListMap.containsKey(fields[8].trim().toUpperCase())) + if(fields[8] == null || fields[8].isEmpty() || !optimalElitopeListMap.containsKey(fields[8].trim().toUpperCase())) errors.reject(null,"Line number : "+lineNo+" If the peptide is a child then the value for 'IN A LIST' is required and must pre exist in database.Contact SCHARP to add new Optimal Epitope List"); } else { - if((fields[8] != null && fields[8].length() != 0) || (fields[9] != null && fields[9].length() != 0)) + if((fields[8] != null && !fields[8].isEmpty()) || (fields[9] != null && !fields[9].isEmpty())) errors.reject(null,"Line number : "+lineNo+" If the peptide is not a child then the values for 'IN A LIST' and 'HLA RESTRICTION' are not required."); } } @@ -287,9 +287,9 @@ private Peptides createPeptide(String line,String fileName) throws SQLException peptide.setSequence_length(validateInteger(fields[5].trim())); peptide.setAmino_acid_start_pos(validateInteger(fields[6].trim())); peptide.setAmino_acid_end_pos(validateInteger(fields[7].trim())); - if(fields[8]!=null && fields[8].trim().length() !=0) + if(fields[8]!=null && !fields[8].trim().isEmpty()) peptide.setOptimal_epitope_list_id(optimalElitopeListMap.get(fields[8].trim().toUpperCase()).getOptimal_epitope_list_id()); - if(fields[9] !=null && fields[9].trim().length() !=0) + if(fields[9] !=null && !fields[9].trim().isEmpty()) { String hla = fields[9].trim(); if(hla.charAt(0) == '"') @@ -322,7 +322,7 @@ private boolean validateFirstLine(String line, Errors errors) else{ for(int i = 0;i <10;i++) { - if(fields[i] ==null || fields[i].length() == 0) + if(fields[i] ==null || fields[i].isEmpty()) errors.reject(null,"Line number : 1 in the Peptides file has to be tab delimited and should have 10 fields.\n"+ "'PEPTIDE SEQUENCE','IS CHILD','PROTEIN CATEGORY','PEPTIDE GROUP','ID','SEQUENCE LENGTH',\n" + "'AASTART','AAEND','IN A LIST' and 'HLA RESTRICTION'.\n"+ diff --git a/pepdb/src/org/scharp/atlas/pepdb/PoolImporter.java b/pepdb/src/org/scharp/atlas/pepdb/PoolImporter.java index 21ec2fa0..faae505a 100644 --- a/pepdb/src/org/scharp/atlas/pepdb/PoolImporter.java +++ b/pepdb/src/org/scharp/atlas/pepdb/PoolImporter.java @@ -99,12 +99,12 @@ public boolean process(User user, FileForm form, AttachmentFile poolFile,Errors return false; getPeptidePoolMap(); getPoolTypeMap(); - ArrayList newPPools = new ArrayList(); + ArrayList newPPools = new ArrayList<>(); int lineNo =1; while((line = br.readLine()) != null) { lineNo++; - if(line.trim().length()>0) + if(!line.trim().isEmpty()) { if(validateLine(line,errors,lineNo)) { @@ -124,7 +124,7 @@ public boolean process(User user, FileForm form, AttachmentFile poolFile,Errors if(pPool.getPool_type_id() != poolTypeMap.get("POOL").getPool_type_id()) pPool.setParent_pool_id(peptidePoolMap.get(pPool.getParent_pool_name()).getPeptide_pool_id()); PeptidePool dbPeptidePool = null; - if(peptidePoolMap.get(pPool.getPeptide_pool_name().trim().toUpperCase()).getPeptide_pool_id() == null || peptidePoolMap.get(pPool.getPeptide_pool_name().trim().toUpperCase()).getPeptide_pool_id().toString().length() == 0) + if(peptidePoolMap.get(pPool.getPeptide_pool_name().trim().toUpperCase()).getPeptide_pool_id() == null || peptidePoolMap.get(pPool.getPeptide_pool_name().trim().toUpperCase()).getPeptide_pool_id().toString().isEmpty()) dbPeptidePool= PepDBManager.insertPeptidePool(user,pPool); if(dbPeptidePool != null) peptidePoolMap.put(dbPeptidePool.getPeptide_pool_name().trim().toUpperCase(),dbPeptidePool); @@ -149,12 +149,12 @@ public boolean process(User user, FileForm form, AttachmentFile poolFile,Errors getPeptidePoolMap(); getPeptideSequenceMap(); getPeptideGroupMap(); - ArrayList newpeptidesInPools = new ArrayList(); - HashMap> newpoolPeptides = new HashMap>(); + ArrayList newpeptidesInPools = new ArrayList<>(); + HashMap> newpoolPeptides = new HashMap<>(); while((line = br.readLine()) != null) { lineNo++; - if(line.length()>0) + if(!line.isEmpty()) { if(validatePPLine(line,errors,lineNo,newpoolPeptides)) { @@ -166,7 +166,7 @@ public boolean process(User user, FileForm form, AttachmentFile poolFile,Errors newpoolPeptides.get(poolAssign.getPeptide_pool_id()).add(poolAssign.getPeptide_id()); else { - ArrayList peps = new ArrayList(); + ArrayList peps = new ArrayList<>(); peps.add(poolAssign.getPeptide_id()); newpoolPeptides.put(poolAssign.getPeptide_pool_id(),peps); } @@ -219,7 +219,7 @@ private PeptidePool createPeptidePool(String line) PeptidePool pPool = new PeptidePool(); pPool.setPeptide_pool_name(fields[0].trim()); pPool.setPool_type_id(poolTypeMap.get(fields[1].trim().toUpperCase()).getPool_type_id()); - if(fields[2] != null && fields[2].trim().toUpperCase() != null && fields[2].trim().toUpperCase().length() != 0) + if(fields[2] != null && fields[2].trim().toUpperCase() != null && !fields[2].trim().toUpperCase().isEmpty()) pPool.setParent_pool_name(fields[2].trim().toUpperCase()); if(fields[1].trim().toUpperCase().equalsIgnoreCase("MATRIX")) pPool.setMatrix_peptide_pool_id(fields[3].trim()); @@ -240,7 +240,7 @@ private boolean validateLine(String line,Errors errors,int lineNo) errors.reject(null,"Line number : "+lineNo+"must have 2 fields.The Pool Description File has to be tab delimited and must have the fields 'POOL NAME' and 'POOL TYPE'."); else { - if((fields[0] == null || fields[0].trim().length() == 0) || (fields[1] == null || fields[1].trim().length() == 0)) + if((fields[0] == null || fields[0].trim().isEmpty()) || (fields[1] == null || fields[1].trim().isEmpty())) errors.reject(null,"Line number : "+lineNo+" is missing one of the required field values \n" + "'POOL NAME' and 'POOL TYPE'."); else { @@ -252,23 +252,23 @@ private boolean validateLine(String line,Errors errors,int lineNo) " that does not exist in the database. Check the file and upload again or Contact SCHARP to add new Pool Type."); else { - if (fields[1].trim().toUpperCase().equalsIgnoreCase("MATRIX") && (fields[3] == null || fields[3].trim().length() == 0)) + if (fields[1].trim().toUpperCase().equalsIgnoreCase("MATRIX") && (fields[3] == null || fields[3].trim().isEmpty())) errors.reject(null,"Line number : "+lineNo+" is missing 'MATRIX POOL ID' " + fields[1] + " for 'POOL TYPE' 'MATRIX'. Check the file and upload again or Contact SCHARP to add new Pool Type."); - if (!fields[1].trim().toUpperCase().equalsIgnoreCase("MATRIX") && (fields[3] != null && fields[3].trim().length() != 0)) + if (!fields[1].trim().toUpperCase().equalsIgnoreCase("MATRIX") && (fields[3] != null && !fields[3].trim().isEmpty())) errors.reject(null,"Line number : "+lineNo+" has 'MATRIX POOL ID' " + fields[1] + " for 'POOL TYPE' other than 'MATRIX' which is not expected. Check the file and upload again or Contact SCHARP to add new Pool Type."); - if (fields[1].trim().toUpperCase().equalsIgnoreCase("POOL") && (fields[2] != null && fields[2].trim().length() != 0)) + if (fields[1].trim().toUpperCase().equalsIgnoreCase("POOL") && (fields[2] != null && !fields[2].trim().isEmpty())) errors.reject(null,"Line number : "+lineNo+" has 'PARENT POOL NAME' " + fields[1] + " for 'POOL TYPE' 'POOL' which is not expected. Check the file and upload again or Contact SCHARP to add new Pool Type."); - if ((!fields[1].trim().toUpperCase().equalsIgnoreCase("POOL") && !fields[1].trim().toUpperCase().equalsIgnoreCase("OTHER")) && (fields[2] == null || fields[2].trim().length() == 0)) + if ((!fields[1].trim().toUpperCase().equalsIgnoreCase("POOL") && !fields[1].trim().toUpperCase().equalsIgnoreCase("OTHER")) && (fields[2] == null || fields[2].trim().isEmpty())) errors.reject(null,"Line number : "+lineNo+" is missing 'PARENT POOL NAME' " + fields[1] + " for 'POOL TYPE' other than 'POOL' and 'OTHER'. Check the file and upload again or Contact SCHARP to add new Pool Type."); - else if(fields[2] != null && fields[2].trim().length() != 0) + else if(fields[2] != null && !fields[2].trim().isEmpty()) { if(!peptidePoolMap.containsKey(fields[2].trim().toUpperCase())) errors.reject(null,"Line number : "+lineNo+" contains the 'PARENT POOL NAME' = '" + fields[2] + @@ -303,7 +303,7 @@ private boolean validatePPLine(String line,Errors errors,int lineNo,HashMap