Skip to content
Snippets Groups Projects
Commit e8a17357 authored by anttil's avatar anttil
Browse files

BIS-341 / SP-536 : Fix for case where both component and container are...

BIS-341 / SP-536 : Fix for case where both component and container are identified by only their codes and space is read from default space of the import file

SVN: 28559
parent 0a6ff75a
No related branches found
No related tags found
No related merge requests found
......@@ -278,7 +278,6 @@ public class SampleDAO extends AbstractGenericEntityWithPropertiesDAO<SamplePE>
Criteria criteria = createSpaceCriteria(space);
addSampleCodesCriterion(criteria, sampleCodes, containerCodeOrNull);
criteria.setFetchMode("contained", FetchMode.JOIN);
List<SamplePE> result = cast(criteria.list());
if (operationLog.isDebugEnabled())
{
......
......@@ -102,9 +102,17 @@ public class NormalizedSampleIdentifier
+ " and " + sample.getContainerIdentifier());
} else if (sample.getCurrentContainerIdentifier() != null)
{
String[] split = sample.getCurrentContainerIdentifier().split("/");
this.containerSpace = split[1];
this.containerCode = split[2];
String containerIdentifier = sample.getCurrentContainerIdentifier();
if (containerIdentifier.contains("/"))
{
String[] split = sample.getCurrentContainerIdentifier().split("/");
this.containerSpace = split[1];
this.containerCode = split[2];
} else
{
this.containerSpace = space;
this.containerCode = containerIdentifier;
}
}
}
......
......@@ -203,7 +203,31 @@ public class GeneralBatchImportRegistrationTest extends MainSuite
assertThat(browserEntryOf(component), hasSpace(defaultSpace));
assertThat(browserEntryOf(component), hasContainer(container));
}
@Test
public void containerColumnCanContainOnlyCodeOfContainerIfDefaultSpaceOfImportFileIsSet()
throws Exception
{
GeneralBatchImportFile file =
create(aGeneralBatchImportFile()
.withSampleContainerColumn()
.withDefaultSpace(defaultSpace));
Sample container =
create(in(file),
aSample().ofType(basic).in(defaultSpace),
IdentifiedBy.CODE);
Sample component =
create(in(file),
aSample().ofType(componentType).containedBy(container),
IdentifiedBy.SUBCODE);
generalBatchImport(file);
assertThat(browserEntryOf(component), hasSpace(defaultSpace));
assertThat(browserEntryOf(component), hasContainer(container));
}
@Test(expectedExceptions = CommandNotSuccessful.class)
......@@ -261,24 +285,6 @@ public class GeneralBatchImportRegistrationTest extends MainSuite
assertThat(browserEntryOf(sample), containsValue(propertyType.getLabel(), propertyValue));
}
@Test(enabled = false)
public void IdentifierColumnCanBeEmptyForSamplesWhoseTypeDefinesTheirCodesToBeCreatedAutomatically()
throws Exception
{
SampleType sampleType = create(aSampleType().thatGeneratesCodes());
PropertyType propertyType = create(aVarcharPropertyType());
create(aSamplePropertyTypeAssignment().with(sampleType).with(propertyType));
GeneralBatchImportFile file =
create(aGeneralBatchImportFile().withDefaultSpace(defaultSpace));
create(in(file), aSample().ofType(sampleType).withProperty(propertyType,
randomValue()).in(sampleSpace));
generalBatchImport(file);
Thread.sleep(10000000);
}
@Override
public void fixture()
{
......
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