/** * Returns the full details of the tissue samples with the specified IDs. One or more columns must * be specified before calling this method. The only filters are the sample IDs that are passed to * this method. * * @param sampleIds the array of sample IDs * @return A <code>List</code> of {@link com.ardais.bigr.javabeans.SampleData} beans. */ public List getDetails(String[] sampleIds) { List sampleDataBeans = new ArrayList(); Map sampleMap = new HashMap(); int numIds = sampleIds.length; for (int i = 0; i < numIds; i++) { String id = sampleIds[i]; SampleData sample = new SampleData(); sample.setSampleId(id); sampleMap.put(id, sample); sampleDataBeans.add(sample); } getDetails(sampleMap); return sampleDataBeans; }
private String getSampleInfo(HashMap sampleNumberToSample, SecurityInfo securityInfo) { Set problems = new HashSet(); List encounteredAliases = new ArrayList(); Iterator i = sampleNumberToSample.keySet().iterator(); while (i.hasNext()) { String sampleNumber = (String) i.next(); String sampleIdOrAlias = (String) sampleNumberToSample.get(sampleNumber); String sampleTypeCui = null; String sampleAlias = null; // if the value begins with the prefix for any of our sample ids (FR, PA, SX) then // assume it is a sample id. Return an error if the sample doesn't exist. if (IltdsUtils.isSystemSampleId(sampleIdOrAlias)) { try { SampleAccessBean sample = new SampleAccessBean(new SampleKey(sampleIdOrAlias)); sampleTypeCui = sample.getSampleTypeCid(); sampleAlias = sample.getCustomerId(); } catch (ObjectNotFoundException e) { StringBuffer error = new StringBuffer(100); error.append("Sample "); error.append(sampleIdOrAlias); error.append(" does not exist in the database."); problems.add(error.toString()); } catch (Exception e) { ApiFunctions.throwAsRuntimeException(e); } } // if the value does not begin with the prefix for any of our sample ids (FR, PA, SX) then // assume it is a sample alias and handle the alias as follows: // - if the alias corresponds to multiple existing sample ids, return an error. // - if the alias corresponds to a single existing sample id, see if the account to which that // sample belongs requires unique aliases. // - if not, return an error since we cannot be positive the sample we found was the one // intended. // - if so // - if the specified alias has already been encountered return an error since the // same sample cannot be scanned into multiple locations in a box. // - if the alias has not yet been encountered then get the information for that // sample. // - if the alias corresponds to no existing sample return an error. else { // pass false to the findSampleIdsFromCustomerId call, to take into account any samples that // have been created via a box scan but have not yet been annotated. List existingSamples = IltdsUtils.findSamplesFromCustomerId(sampleIdOrAlias, false); // if multiple samples with the specified alias were found, return an error. if (existingSamples.size() > 1) { StringBuffer error = new StringBuffer(100); error.append("The alias \""); error.append(Escaper.htmlEscapeAndPreserveWhitespace(sampleIdOrAlias)); error.append("\" corresponds to multiple existing samples. Please scan the specific"); error.append(" sample id you wish to use."); problems.add(error.toString()); } // if a single sample was found, do some further checking else if (existingSamples.size() == 1) { String accountId = ((SampleData) existingSamples.get(0)).getArdaisAcctKey(); AccountDto accountDto = IltdsUtils.getAccountById(accountId, false, false); boolean aliasMustBeUnique = FormLogic.DB_YES.equalsIgnoreCase(accountDto.getRequireUniqueSampleAliases()); // if the account to which the sample belongs does not require unique sample aliases, // return an error since we cannot be sure the sample we found was the one intended. if (!aliasMustBeUnique) { StringBuffer error = new StringBuffer(100); error.append("The alias \""); error.append(Escaper.htmlEscapeAndPreserveWhitespace(sampleIdOrAlias)); error.append("\" does not uniquely identify a sample."); error.append(" Please scan the specific sample id you wish to use."); problems.add(error.toString()); } // if we've already encountered this alias, return an error (the same sample cannot // be scanned into multiple locations in a box) else if (encounteredAliases.contains(sampleIdOrAlias.toUpperCase())) { StringBuffer error = new StringBuffer(100); error.append("The alias \""); error.append(Escaper.htmlEscapeAndPreserveWhitespace(sampleIdOrAlias)); error.append("\" appears more than once."); problems.add(error.toString()); // still fill in the sample information so the resulting screen looks correct (otherwise // the first instance of this alias has information but the second does not) SampleData sample = (SampleData) existingSamples.get(0); sampleIdOrAlias = sample.getSampleId(); sampleTypeCui = sample.getSampleTypeCui(); sampleAlias = sample.getSampleAlias(); } // otherwise store the encountered alias (in uppercase, so we can compare subsequent // aliases to this one without case accounting for any differences) and get the // information // for the sample else { encounteredAliases.add(sampleIdOrAlias.toUpperCase()); SampleData sample = (SampleData) existingSamples.get(0); sampleIdOrAlias = sample.getSampleId(); sampleTypeCui = sample.getSampleTypeCui(); sampleAlias = sample.getSampleAlias(); } } // if no matching sample was found, return an error else { StringBuffer error = new StringBuffer(100); error.append("Sample \""); error.append(Escaper.htmlEscapeAndPreserveWhitespace(sampleIdOrAlias)); error.append("\" does not exist in the database."); problems.add(error.toString()); } } // Create a sample data to hold the information SampleData sample = new SampleData(); sample.setSampleId(sampleIdOrAlias); sample.setSampleAlias(sampleAlias); sample.setSampleTypeCui(sampleTypeCui); if (!ApiFunctions.isEmpty(sampleTypeCui)) { sample.setSampleType(GbossFactory.getInstance().getDescription(sampleTypeCui)); } // replace the map entry with the sample data object sampleNumberToSample.put(sampleNumber, sample); } String returnValue = null; if (!problems.isEmpty()) { StringBuffer buff = new StringBuffer("The following problems were found: "); Iterator problemIterator = problems.iterator(); while (problemIterator.hasNext()) { buff.append((String) problemIterator.next()); buff.append(" "); } returnValue = buff.toString(); } return returnValue; }