use of org.jbei.ice.storage.model.Storage in project ice by JBEI.
the class StorageDAO method retrieveStorageByIndex.
/**
* Retrieve a {@link Storage} object by its index and {@link SampleType} fields.
*
* @param index index value
* @param type storage type
* @return List of Storage objects
*/
public List<Storage> retrieveStorageByIndex(String index, SampleType type) {
try {
CriteriaQuery<Storage> query = getBuilder().createQuery(Storage.class);
Root<Storage> from = query.from(Storage.class);
query.where(getBuilder().equal(from.get("index"), index), getBuilder().equal(from.get("storageType"), type));
return currentSession().createQuery(query).list();
} catch (Exception e) {
String msg = "Could not get Storage by index: " + index + " " + e.toString();
Logger.error(msg, e);
throw new DAOException(msg);
}
}
use of org.jbei.ice.storage.model.Storage in project ice by JBEI.
the class SampleServiceTest method testCreateSample.
@Test
public void testCreateSample() throws Exception {
Account account = AccountCreator.createTestAccount("SampleServiceTest.testCreateSample", false);
String userId = account.getEmail();
// create 96 strains
Map<Long, String> idPartNumberMap = new HashMap<>();
for (int i = 0; i < 96; i += 1) {
Strain strain = TestEntryCreator.createTestStrain(account);
Assert.assertNotNull(strain);
idPartNumberMap.put(strain.getId(), strain.getPartNumber());
}
Assert.assertEquals(96, idPartNumberMap.size());
String mainPlate = "0000000001";
// create main plate
createPlateSamples(userId, mainPlate, idPartNumberMap);
List<Storage> storageList = DAOFactory.getStorageDAO().retrieveStorageByIndex(mainPlate, SampleType.PLATE96);
Assert.assertNotNull(storageList);
Assert.assertEquals(1, storageList.size());
// retrieve samples for entries
int i = 0;
for (String partNumber : idPartNumberMap.values()) {
List<PartSample> samples = service.retrieveEntrySamples(userId, partNumber);
Assert.assertNotNull(samples);
Assert.assertTrue(samples.size() == 1);
verifyMainPlate(samples.get(0), i, mainPlate);
i += 1;
}
// create backup 1
String backUp1Plate = "0000000002";
createPlateSamples(userId, backUp1Plate, idPartNumberMap);
storageList = DAOFactory.getStorageDAO().retrieveStorageByIndex(backUp1Plate, SampleType.PLATE96);
Assert.assertNotNull(storageList);
Assert.assertEquals(1, storageList.size());
// retrieve samples for entries
i = 0;
for (String partNumber : idPartNumberMap.values()) {
List<PartSample> samples = service.retrieveEntrySamples(userId, partNumber);
Assert.assertNotNull(samples);
Assert.assertTrue(samples.size() == 2);
verifyMainPlate(samples.get(0), i, mainPlate, backUp1Plate);
verifyMainPlate(samples.get(1), i, mainPlate, backUp1Plate);
i += 1;
}
// create backup 2
String backUp2Plate = "0000000003";
createPlateSamples(userId, backUp2Plate, idPartNumberMap);
storageList = DAOFactory.getStorageDAO().retrieveStorageByIndex(backUp1Plate, SampleType.PLATE96);
Assert.assertNotNull(storageList);
Assert.assertEquals(1, storageList.size());
// retrieve samples for entries
i = 0;
for (String partNumber : idPartNumberMap.values()) {
List<PartSample> samples = service.retrieveEntrySamples(userId, partNumber);
Assert.assertNotNull(samples);
Assert.assertTrue(samples.size() == 3);
verifyMainPlate(samples.get(0), i, mainPlate, backUp1Plate, backUp2Plate);
verifyMainPlate(samples.get(1), i, mainPlate, backUp1Plate, backUp2Plate);
verifyMainPlate(samples.get(2), i, mainPlate, backUp1Plate, backUp2Plate);
i += 1;
}
}
use of org.jbei.ice.storage.model.Storage in project ice by JBEI.
the class SampleServiceTest method createStorage.
@Test
public void createStorage() throws Exception {
Storage storage = service.createStorage("user1", "test1", SampleType.ADDGENE);
Assert.assertNotNull(storage);
Assert.assertEquals(storage.getIndex(), "test1");
Assert.assertEquals(storage.getOwnerEmail(), "user1");
Assert.assertEquals(storage.getStorageType().name(), SampleType.ADDGENE.name());
}
Aggregations