Skip to content
Snippets Groups Projects
Commit e2fd33a0 authored by kaloyane's avatar kaloyane
Browse files

[LMS-2163] fixed + unit test

SVN: 20624
parent 5e6847bc
No related branches found
No related tags found
No related merge requests found
...@@ -201,11 +201,30 @@ public class WellContentLoader ...@@ -201,11 +201,30 @@ public class WellContentLoader
private List<WellContent> loadLocationsAndEnrich(WellSearchCriteria materialCriteria) private List<WellContent> loadLocationsAndEnrich(WellSearchCriteria materialCriteria)
{ {
List<WellContent> locations = loadLocations(materialCriteria); List<WellContent> locations = loadLocations(materialCriteria);
List<WellContent> withProperties = enrichWithWellProperties(locations); List<WellContent> uniqueLocations = filterWellDuplicates(locations);
List<WellContent> withProperties = enrichWithWellProperties(uniqueLocations);
List<WellContent> withPropsAndDataSets = enrichWithDatasets(withProperties); List<WellContent> withPropsAndDataSets = enrichWithDatasets(withProperties);
return enrichWithFeatureVectors(withPropsAndDataSets); return enrichWithFeatureVectors(withPropsAndDataSets);
} }
private List<WellContent> filterWellDuplicates(List<WellContent> wellContents)
{
Set<String> seenPermIds = new HashSet<String>();
ArrayList<WellContent> filtered = new ArrayList<WellContent>();
for (WellContent content : wellContents)
{
String wellPermId = content.getWell().getPermId();
if (false == seenPermIds.contains(wellPermId))
{
seenPermIds.add(wellPermId);
filtered.add(content);
}
}
return filtered;
}
private List<WellContent> enrichWithWellProperties(List<WellContent> locations) private List<WellContent> enrichWithWellProperties(List<WellContent> locations)
{ {
Map<Long /* id */, WellContent> wellContents = new HashMap<Long/* id */, WellContent>(); Map<Long /* id */, WellContent> wellContents = new HashMap<Long/* id */, WellContent>();
...@@ -754,6 +773,7 @@ public class WellContentLoader ...@@ -754,6 +773,7 @@ public class WellContentLoader
DataIterator<ch.systemsx.cisd.openbis.plugin.screening.server.dataaccess.WellContent> locations) DataIterator<ch.systemsx.cisd.openbis.plugin.screening.server.dataaccess.WellContent> locations)
{ {
List<WellContent> wellLocations = new ArrayList<WellContent>(); List<WellContent> wellLocations = new ArrayList<WellContent>();
for (ch.systemsx.cisd.openbis.plugin.screening.server.dataaccess.WellContent location : locations) for (ch.systemsx.cisd.openbis.plugin.screening.server.dataaccess.WellContent location : locations)
{ {
wellLocations.add(convert(location)); wellLocations.add(convert(location));
......
...@@ -71,19 +71,15 @@ public class WellContentLoaderTest extends AbstractScreeningDAOTest ...@@ -71,19 +71,15 @@ public class WellContentLoaderTest extends AbstractScreeningDAOTest
List<WellContent> wellContents = List<WellContent> wellContents =
WellContentLoader.load(session, businessObjectFactory, daoFactory, searchCriteria); WellContentLoader.load(session, businessObjectFactory, daoFactory, searchCriteria);
// the test database contains two matching wells
assertEquals(1, wellContents.size()); assertEquals(1, wellContents.size());
for (WellContent wc : wellContents) assertPropertiesPresent(wellContents.get(0));
{
assertPropertiesPresent(wc);
}
} }
/** /**
* Test that the same well is not displayed twice if the search query matches two different * Test that the same well is not displayed twice if the search query matches two different
* materials inside the well. * materials inside the well.
*/ */
@Test(enabled = false) @Test
public void testDuplicateWellsFilteredOut() public void testDuplicateWellsFilteredOut()
{ {
String[] materialCodes = new String[] String[] materialCodes = new String[]
...@@ -100,12 +96,8 @@ public class WellContentLoaderTest extends AbstractScreeningDAOTest ...@@ -100,12 +96,8 @@ public class WellContentLoaderTest extends AbstractScreeningDAOTest
List<WellContent> wellContents = List<WellContent> wellContents =
WellContentLoader.load(session, businessObjectFactory, daoFactory, searchCriteria); WellContentLoader.load(session, businessObjectFactory, daoFactory, searchCriteria);
// the test database contains two matching wells assertEquals(1, wellContents.size());
assertEquals(2, wellContents.size()); assertPropertiesPresent(wellContents.get(0));
for (WellContent wc : wellContents)
{
assertPropertiesPresent(wc);
}
} }
private void assertPropertiesPresent(WellContent wellContent) private void assertPropertiesPresent(WellContent wellContent)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment