use of org.jbei.ice.lib.entry.EntrySelection 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.entry.EntrySelection in project ice by JBEI.
the class FolderContentsTest method testAddEntrySelection.
@Test
public void testAddEntrySelection() throws Exception {
// create account
Account account = AccountCreator.createTestAccount("FolderContentsTest.testAddEntrySelection", true);
String userId = account.getEmail();
Account user = AccountCreator.createTestAccount("FolderContentsTest.testAddEntrySelection2", false);
// create folder
FolderDetails folderDetails = new FolderDetails();
folderDetails.setName("testAdd");
folderDetails.setOwner(user.toDataTransferObject());
FolderController controller = new FolderController();
folderDetails = controller.createPersonalFolder(userId, folderDetails);
Assert.assertNotNull(folderDetails);
// check folder ownership
Assert.assertEquals(1, controller.getUserFolders(user.getEmail()).size());
// entry selection context for adding to folder
EntrySelection selection = new EntrySelection();
selection.setSelectionType(EntrySelectionType.FOLDER);
selection.getDestination().add(folderDetails);
// create entries
long id = TestEntryCreator.createTestPart(userId);
selection.getEntries().add(id);
id = TestEntryCreator.createTestPart(userId);
selection.getEntries().add(id);
// add to folder
FolderContents folderContents = new FolderContents();
List<FolderDetails> folders = folderContents.addEntrySelection(userId, selection);
Assert.assertNotNull(folders);
}
use of org.jbei.ice.lib.entry.EntrySelection in project ice by JBEI.
the class RemoteTransfer method transferFolder.
public FolderDetails transferFolder(long remoteId, FolderDetails folderDetails, List<Long> remoteIds) {
RemotePartner partner = this.remotePartnerDAO.get(remoteId);
if (partner == null)
throw new IllegalArgumentException("Invalid remote host id: " + remoteId);
FolderDetails details = remoteContact.transferFolder(partner.getUrl(), folderDetails);
if (folderDetails == null) {
Logger.error("Could not create remote folder");
return null;
}
if (remoteIds == null || remoteIds.isEmpty()) {
Logger.info("Skipping transfer of entries. List is empty");
return details;
}
// move entries to the transferred entries
EntrySelection entrySelection = new EntrySelection();
entrySelection.getEntries().addAll(remoteIds);
entrySelection.getDestination().add(details);
entrySelection.setSelectionType(EntrySelectionType.FOLDER);
remoteContact.addTransferredEntriesToFolder(partner.getUrl(), entrySelection);
return details;
}
Aggregations