use of com.github.jmchilton.blend4j.galaxy.beans.FilesystemPathsLibraryUpload in project irida by phac-nml.
the class GalaxyHistoriesServiceIT method setupLibraries.
/**
* Sets up library for test.
* @param testLibrary The library to upload a file to.
* @param galaxyInstanceAdmin The Galaxy Instance to connect to Galaxy.
* @return Returns the id of the file in a library.
* @throws CreateLibraryException
* @throws ExecutionManagerObjectNotFoundException
*/
private String setupLibraries(Library testLibrary, GalaxyInstance galaxyInstanceAdmin) throws CreateLibraryException, ExecutionManagerObjectNotFoundException {
LibrariesClient librariesClient = galaxyInstanceAdmin.getLibrariesClient();
LibraryContent rootFolder = librariesClient.getRootFolder(testLibrary.getId());
assertNotNull(rootFolder);
FilesystemPathsLibraryUpload upload = new FilesystemPathsLibraryUpload();
upload.setFolderId(rootFolder.getId());
upload.setContent(dataFile.toFile().getAbsolutePath());
upload.setName(dataFile.toFile().getName());
upload.setLinkData(true);
upload.setFileType(FILE_TYPE.toString());
assertEquals(ClientResponse.Status.OK, librariesClient.uploadFilesystemPathsRequest(testLibrary.getId(), upload).getClientResponseStatus());
List<LibraryContent> libraryContents = librariesClient.getLibraryContents(testLibrary.getId());
Map<String, List<LibraryContent>> libraryContent = libraryContents.stream().collect(Collectors.groupingBy(LibraryContent::getName));
LibraryContent fileContent = libraryContent.get("/" + dataFile.toFile().getName()).get(0);
assertNotNull(fileContent);
return fileContent.getId();
}
use of com.github.jmchilton.blend4j.galaxy.beans.FilesystemPathsLibraryUpload in project irida by phac-nml.
the class GalaxyLibrariesService method fileToLibrary.
/**
* Uploads the given file to a library with the given information.
*
* @param path
* The path of the file to upload.
* @param fileType
* The type of the file to upload.
* @param library
* The library to upload the file into.
* @param dataStorage
* The {@link DataStorage} method to apply to this dataset.
* @return A dataset id for the dataset in this library.
* @throws UploadException
* If there was an issue uploading the file to the library.
*/
public String fileToLibrary(Path path, InputFileType fileType, Library library, DataStorage dataStorage) throws UploadException {
checkNotNull(path, "path is null");
checkNotNull(fileType, "fileType is null");
checkNotNull(library, "library is null");
checkNotNull(library.getId(), "library id is null");
checkState(path.toFile().exists(), "path " + path + " does not exist");
File file = path.toFile();
try {
LibraryContent rootContent = librariesClient.getRootFolder(library.getId());
FilesystemPathsLibraryUpload upload = new FilesystemPathsLibraryUpload();
upload.setFolderId(rootContent.getId());
upload.setContent(file.getAbsolutePath());
upload.setName(file.getName());
upload.setLinkData(DataStorage.LOCAL.equals(dataStorage));
upload.setFileType(fileType.toString());
GalaxyObject uploadObject = librariesClient.uploadFilesystemPaths(library.getId(), upload);
return uploadObject.getId();
} catch (RuntimeException e) {
throw new UploadException(e);
}
}
Aggregations