use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class EntryLinks method get.
/**
* Retrieves entry links that are parents or children depending on specified type
*
* @param type specified type of links to return
* @return list of links that match specified type. These are filtered based on user permissions
*/
public List<PartData> get(LinkType type) {
List<Entry> entries;
if (type == LinkType.CHILD) {
entries = new ArrayList<>(this.entry.getLinkedEntries());
} else {
entries = this.entryDAO.getParents(this.entry.getId());
}
// get sequence and other summary information
List<PartData> results = new ArrayList<>(entries.size());
for (Entry entry : entries) {
if (!this.entryAuthorization.canRead(this.userId, entry))
continue;
PartData partData = new PartData(EntryType.nameToType(entry.getRecordType()));
partData.setId(entry.getId());
partData.setName(entry.getName());
partData.setPartId(entry.getPartNumber());
partData.setShortDescription(entry.getShortDescription());
boolean hasSequence = sequenceDAO.hasSequence(entry.getId());
partData.setHasSequence(hasSequence);
boolean hasOriginalSequence = sequenceDAO.hasOriginalSequence(entry.getId());
partData.setHasOriginalSequence(hasOriginalSequence);
Optional<String> sequenceString = sequenceDAO.getSequenceString(entry);
if (sequenceString.isPresent()) {
String sequence = sequenceString.get();
int featureCount = sequenceFeatureDAO.getFeatureCount(entry);
partData.setBasePairCount(sequence.trim().length());
partData.setFeatureCount(featureCount);
} else {
partData.setBasePairCount(0);
}
results.add(partData);
}
return results;
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class FolderContents method addToRemoteFolder.
// transfer entries to remote partner and add to folder
protected void addToRemoteFolder(Account account, Folder folder, List<Long> entries) {
RemoteAccessModel remoteAccessModel = remoteAccessModelDAO.getByFolder(account, folder);
if (remoteAccessModel == null) {
Logger.error("Could not retrieve remote access for folder " + folder.getId());
return;
}
RemotePartner remotePartner = remoteAccessModel.getRemoteClientModel().getRemotePartner();
RemoteTransfer remoteTransfer = new RemoteTransfer();
List<PartData> results = remoteTransfer.getPartsForTransfer(entries);
List<Long> remoteIds = remoteTransfer.transferEntries(remotePartner.getId(), results);
FolderDetails remoteFolder = new FolderDetails();
remoteFolder.setId(Long.decode(remoteAccessModel.getIdentifier()));
// add transferred entries to the folder
EntrySelection selection = new EntrySelection();
selection.getEntries().addAll(remoteIds);
selection.getDestination().add(remoteFolder);
selection.setSelectionType(EntrySelectionType.FOLDER);
String token = remoteAccessModel.getToken();
remoteContact.addTransferredEntriesToFolder(remotePartner.getUrl(), account.getEmail(), selection, remoteFolder.getId(), token, remotePartner.getApiKey());
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class Strain method toDataTransferObject.
@Override
public PartData toDataTransferObject() {
PartData data = super.toDataTransferObject();
StrainData strainData = new StrainData();
strainData.setGenotypePhenotype(genotypePhenotype);
strainData.setHost(host);
data.setStrainData(strainData);
return data;
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class Request method toDataTransferObject.
@Override
public SampleRequest toDataTransferObject() {
SampleRequest sampleRequest = new SampleRequest();
sampleRequest.setId(getId());
sampleRequest.setRequestType(getType());
sampleRequest.setStatus(getStatus());
if (growthTemperature != null)
sampleRequest.setGrowthTemperature(growthTemperature);
sampleRequest.setPlateDescription(plateDescription);
EntryType type = EntryType.nameToType(entry.getRecordType());
PartData data = new PartData(type);
data.setId(entry.getId());
data.setPartId(entry.getPartNumber());
data.setSelectionMarkers(EntryUtil.getSelectionMarkersAsList(entry.getSelectionMarkers()));
data.setName(entry.getName());
sampleRequest.setPartData(data);
sampleRequest.setRequester(getAccount().toDataTransferObject());
sampleRequest.setRequestTime(getRequested().getTime());
sampleRequest.setUpdateTime(getUpdated() == null ? sampleRequest.getRequestTime() : getUpdated().getTime());
return sampleRequest;
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class FolderContentsTest method testGetContents.
@Test
public void testGetContents() throws Exception {
FolderContents folderContents = new FolderContents();
// test with null id
folderContents.getContents(null, 0, new PageParameters(0, 10, ColumnField.PART_ID, false, null));
Account account = AccountCreator.createTestAccount("testRetrieveFolderContents", false);
String userId = account.getEmail();
FolderDetails folderDetails = new FolderDetails();
folderDetails.setName("test");
// create folder
FolderDetails folder = createPersonalFolder(userId, folderDetails);
Assert.assertNotNull(folder);
final short size = 105;
// create 100 test strains
HashMap<String, Entry> parts = new HashMap<>();
List<Long> entryList = new ArrayList<>();
for (int i = 0; i < size; i += 1) {
Strain strain = TestEntryCreator.createTestStrain(account);
Assert.assertNotNull(strain);
parts.put(strain.getPartNumber(), strain);
entryList.add(strain.getId());
}
Assert.assertEquals(size, parts.size());
// add to folder
List<FolderDetails> foldersToAdd = new ArrayList<>();
foldersToAdd.add(folder);
foldersToAdd = folderContents.addEntriesToFolders(account.getEmail(), entryList, foldersToAdd);
Assert.assertNotNull(foldersToAdd);
// keep track to find duplicates
HashSet<Long> set = new HashSet<>();
// retrieve (supported sort types created, status, name, part_id, type)
FolderDetails details = folderContents.getContents(account.getEmail(), folder.getId(), new PageParameters(0, 15, ColumnField.PART_ID, false, null));
Assert.assertNotNull(details);
short pageSize = 15;
int it = 1;
while (!details.getEntries().isEmpty()) {
Assert.assertEquals(pageSize, details.getEntries().size());
for (PartData partData : details.getEntries()) {
Assert.assertNotNull(parts.remove(partData.getPartId()));
Assert.assertFalse(set.contains(partData.getId()));
set.add(partData.getId());
}
// check remaining
Assert.assertEquals((size - (it * pageSize)), parts.size());
details = folderContents.getContents(account.getEmail(), folder.getId(), new PageParameters(pageSize * it, pageSize, ColumnField.PART_ID, false, null));
it += 1;
}
}
Aggregations