├── .classpath ├── .gitignore ├── .project ├── .settings ├── org.eclipse.jdt.core.prefs └── org.eclipse.m2e.core.prefs ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── nb-configuration.xml ├── pom.xml ├── release.sh ├── src ├── main │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── jmchilton │ │ │ └── blend4j │ │ │ ├── BaseClient.java │ │ │ ├── Config.java │ │ │ ├── exceptions │ │ │ ├── ApiException.java │ │ │ ├── ResponseException.java │ │ │ └── SerializationException.java │ │ │ ├── galaxy │ │ │ ├── Client.java │ │ │ ├── ConfigurationClient.java │ │ │ ├── ConfigurationClientImpl.java │ │ │ ├── DefaultWebResourceFactoryImpl.java │ │ │ ├── GalaxyAuthWebResourceFactoryImpl.java │ │ │ ├── GalaxyInstance.java │ │ │ ├── GalaxyInstanceFactory.java │ │ │ ├── GalaxyInstanceImpl.java │ │ │ ├── GalaxyResponseException.java │ │ │ ├── HistoriesClient.java │ │ │ ├── HistoriesClientImpl.java │ │ │ ├── JobsClient.java │ │ │ ├── JobsClientImpl.java │ │ │ ├── LibrariesClient.java │ │ │ ├── LibrariesClientImpl.java │ │ │ ├── RolesClient.java │ │ │ ├── RolesClientImpl.java │ │ │ ├── SearchClient.java │ │ │ ├── SearchClientImpl.java │ │ │ ├── SslHacking.java │ │ │ ├── ToolDataClient.java │ │ │ ├── ToolDataClientImpl.java │ │ │ ├── ToolShedRepositoriesClient.java │ │ │ ├── ToolShedRepositoriesClientImpl.java │ │ │ ├── ToolsClient.java │ │ │ ├── ToolsClientImpl.java │ │ │ ├── UsersClient.java │ │ │ ├── UsersClientImpl.java │ │ │ ├── WebResourceFactory.java │ │ │ ├── WorkflowsClient.java │ │ │ ├── WorkflowsClientImpl.java │ │ │ └── beans │ │ │ │ ├── Dataset.java │ │ │ │ ├── DirectoryLibraryUpload.java │ │ │ │ ├── FileLibraryUpload.java │ │ │ │ ├── FilesystemPathsLibraryUpload.java │ │ │ │ ├── GalaxyObject.java │ │ │ │ ├── HasGalaxyUrl.java │ │ │ │ ├── History.java │ │ │ │ ├── HistoryContents.java │ │ │ │ ├── HistoryContentsProvenance.java │ │ │ │ ├── HistoryDataset.java │ │ │ │ ├── HistoryDeleteResponse.java │ │ │ │ ├── HistoryDetails.java │ │ │ │ ├── HistoryExport.java │ │ │ │ ├── InstallableRepositoryRevision.java │ │ │ │ ├── InstalledRepository.java │ │ │ │ ├── Job.java │ │ │ │ ├── JobDetails.java │ │ │ │ ├── JobInputOutput.java │ │ │ │ ├── Library.java │ │ │ │ ├── LibraryContent.java │ │ │ │ ├── LibraryDataset.java │ │ │ │ ├── LibraryFolder.java │ │ │ │ ├── LibraryPermissions.java │ │ │ │ ├── LibraryUpload.java │ │ │ │ ├── OutputDataset.java │ │ │ │ ├── RepositoryInstall.java │ │ │ │ ├── RepositoryWorkflow.java │ │ │ │ ├── Role.java │ │ │ │ ├── TabularToolDataTable.java │ │ │ │ ├── Tool.java │ │ │ │ ├── ToolExecution.java │ │ │ │ ├── ToolInputs.java │ │ │ │ ├── ToolParameter.java │ │ │ │ ├── ToolSection.java │ │ │ │ ├── UrlLibraryUpload.java │ │ │ │ ├── User.java │ │ │ │ ├── UserCreate.java │ │ │ │ ├── Workflow.java │ │ │ │ ├── WorkflowDetails.java │ │ │ │ ├── WorkflowInputDefinition.java │ │ │ │ ├── WorkflowInputs.java │ │ │ │ ├── WorkflowInvocationInputs.java │ │ │ │ ├── WorkflowInvocationOutputs.java │ │ │ │ ├── WorkflowOutputs.java │ │ │ │ ├── WorkflowStepDefinition.java │ │ │ │ └── collection │ │ │ │ ├── CollectionSource.java │ │ │ │ ├── request │ │ │ │ ├── AbstractElement.java │ │ │ │ ├── CollectionDescription.java │ │ │ │ ├── CollectionElement.java │ │ │ │ ├── HistoryDatasetElement.java │ │ │ │ └── SimpleElement.java │ │ │ │ └── response │ │ │ │ ├── CollectionElementResponse.java │ │ │ │ ├── CollectionResponse.java │ │ │ │ └── ElementResponse.java │ │ │ ├── toolshed │ │ │ ├── Client.java │ │ │ ├── RepositoriesClient.java │ │ │ ├── RepositoriesClientImpl.java │ │ │ ├── RepositoryUtils.java │ │ │ ├── ToolShedInstance.java │ │ │ ├── ToolShedInstanceFactory.java │ │ │ ├── ToolShedInstanceImpl.java │ │ │ ├── ToolShedUtils.java │ │ │ └── beans │ │ │ │ ├── Repository.java │ │ │ │ ├── RepositoryDetails.java │ │ │ │ └── RepositoryRevision.java │ │ │ └── util │ │ │ ├── MoreObjects.java │ │ │ ├── Objects.java │ │ │ ├── Preconditions.java │ │ │ └── package-info.java │ └── javadoc │ │ ├── overview.html │ │ └── resources │ │ └── syntaxhighlighterstyle.css └── test │ ├── java │ └── com │ │ └── github │ │ └── jmchilton │ │ └── blend4j │ │ ├── galaxy │ │ ├── ConfigurationTest.java │ │ ├── Examples.java │ │ ├── HistoriesTest.java │ │ ├── IntegrationTest.java │ │ ├── JobsTest.java │ │ ├── LibrariesTest.java │ │ ├── ObjectMapperTest.java │ │ ├── SearchTest.java │ │ ├── TestGalaxyInstance.java │ │ ├── TestHelpers.java │ │ ├── ToolDataTest.java │ │ ├── ToolShedRepositoriesTest.java │ │ ├── ToolsTest.java │ │ ├── UserTest.java │ │ └── WorkflowsTest.java │ │ └── toolshed │ │ └── RepositoriesClientTest.java │ └── resources │ ├── com │ └── github │ │ └── jmchilton │ │ └── blend4j │ │ └── galaxy │ │ ├── TestWorkflow1.ga │ │ ├── TestWorkflowCollectionList.ga │ │ ├── TestWorkflowRandomlines.ga │ │ ├── collection_list.xml │ │ └── tool_conf_test.xml │ └── log4j.properties └── ssl ├── InstallCert$SavingTrustManager.class ├── InstallCert.class ├── InstallCert.java └── SSLPoke.class /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | test-output -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | blend4j 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 3 | org.eclipse.jdt.core.compiler.compliance=1.5 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.5 6 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk8 4 | before_install: 5 | - sudo apt-get update -qq 6 | - sudo apt-get install -qq mercurial libsqlite3-dev python-dev python-virtualenv samtools bedtools 7 | install: 8 | - mvn -version 9 | - mvn clean package install -DskipTests -Dgpg.skip 10 | after_failure: 11 | - echo "Tests failed, dumping all logs." 12 | - cat /tmp/**/bootstrap-log/* 13 | script: travis_wait mvn test -B 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # blend4j changelog 2 | 3 | ## [0.2.1][021release] (Jan 22, 2020) 4 | 5 | - Added `invokeWorkflow` to `WorkflowsClient` to be used instead of `runWorkflow`. 6 | - Added updated `importWorkfow(String json, boolean publish)` to `WorkflowsClient` that should be used over the deprecated `importWorkflow(String json)`. 7 | 8 | ## [0.2.0][020release] (March 26, 2018) 9 | 10 | - Update to [galaxy-bootstrap 0.7.0][gxbootstrap070]. 11 | - Added support for accessing Galaxy Tool Data tables. Thanks to Dan Fornika - . 12 | - blend4j now requires Java 1.8+ to run. 13 | 14 | [gxbootstrap070]: http://mvnrepository.com/artifact/com.github.jmchilton.galaxybootstrap/galaxybootstrap/0.7.0 15 | [020release]: http://mvnrepository.com/artifact/com.github.jmchilton.blend4j/blend4j/0.2.0 16 | 17 | ## [0.1.2][012release] (December 18, 2014) 18 | 19 | - Add ability to get information about a [library dataset][getlibrarydataset]. 20 | - Update to [galaxy-bootstrap 0.5.0][gxbootstrap050] to account for recent Galaxy configuration changes. 21 | - Various bug fixes for recent API changes in Galaxy. [1][012bugfix1], [2][012bugfix2], [3][012bugfix3] 22 | 23 | [012release]: http://mvnrepository.com/artifact/com.github.jmchilton.blend4j/blend4j/0.1.2 24 | [getlibrarydataset]: https://github.com/jmchilton/blend4j/commit/e0bd2be2fc93530aa89744701dc96f0591d3894c 25 | [gxbootstrap050]: https://github.com/jmchilton/blend4j/commit/a9a87c3c0b93a2add1572932f39583106cb8c60c 26 | [012bugfix1]: https://github.com/jmchilton/blend4j/commit/f9a5a4bd32424f039ee90c9c1735bc5f90a38973 27 | [012bugfix2]: https://github.com/jmchilton/blend4j/commit/47de71cee239fa4feb975120828429fabac9b500 28 | [012bugfix3]: https://github.com/jmchilton/blend4j/commit/48ff545c1303a5b84b862afae98e6f7f49145d99 29 | 30 | 31 | ## [0.1.1][011release] (August 27, 2014) 32 | 33 | - Dataset collection support by @apetkau. Among other things the [histories client][historiesclient] 34 | can now [create][historiescollectioncreate] and [return][historiescollectionshow] information about collections and the [workflows client][workflowsclient] can [specify][workflowscollectioninput] dataset collections as inputs. 35 | - Documentation overhaul - [API documentation][apidocs] now available online. 36 | - Update tool shed client defaults to reflect the fact main tool shed is now being served over HTTPS. 37 | - Allow authentication with a [username and password][011changesetbasicauth] 38 | instead of an API key. In this case an API key will be generated automatically before the first API call and used for subsequent communication. 39 | - Introduce unified [exception handling][011changesetexceptionhandling]. 40 | Hopefully this will allow clients to decouple exception handling from underlying framework. 41 | - [Improved logging options][011changesetfreekfixes] and [various][011changesetdocfixes1] 42 | [documentation][011changesetdocfixes2] and spelling corrections by @FreekDB. 43 | - Various testing improvements by @apetkau. 44 | 45 | [011release]: http://mvnrepository.com/artifact/com.github.jmchilton.blend4j/blend4j/0.1.1 46 | [011changesetdocfixes1]: https://github.com/jmchilton/blend4j/commit/58abbe03c2223e504ee90e83ffd5626b1afa6b85 47 | [011changesetdocfixes2]: https://github.com/jmchilton/blend4j/commit/3ae570820b4fdb4bad0914349913c909c048b4a7 48 | [011changesetfreekfixes]: https://github.com/jmchilton/blend4j/commit/22de9dd4cec55ca9a68abab2c48c8fa2cddd3a6c 49 | [011changesetexceptionhandling]: https://github.com/jmchilton/blend4j/commit/8e56c8b5adeebf4ce22e672bc16375dab513496b 50 | [011changesetbasicauth]: https://github.com/jmchilton/blend4j/commit/f92909fbda3616da09614b65810ebd86ce496b19 51 | [historiescollectionshow]: http://jmchilton.github.io/blend4j/apidocs/com/github/jmchilton/blend4j/galaxy/HistoriesClient.html#showDatasetCollection(java.lang.String%2C%20java.lang.String) 52 | [historiescollectioncreate]: http://jmchilton.github.io/blend4j/apidocs/com/github/jmchilton/blend4j/galaxy/HistoriesClient.html#createDatasetCollection(java.lang.String%2C%20com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription) 53 | [workflowscollectioninput]: http://jmchilton.github.io/blend4j/apidocs/com/github/jmchilton/blend4j/galaxy/beans/WorkflowInputs.InputSourceType.html 54 | 55 | ## [0.1.0][010release] (May 08, 2014) 56 | 57 | - Parse more information from dataset provenance API calls (job id, standard error, and standard output). [changeset][010changesetprov] 58 | - Parse [more][010changesetcontents1] [information][010changesetcontents2] from dataset contents API calls (purged, hid, history content type, state, dataset info, blurb). 59 | - Bugfixes for importing workflows from an installed tool shed repository. 60 | - Various testing and logging improvements. 61 | 62 | [010release]: http://mvnrepository.com/artifact/com.github.jmchilton.blend4j/blend4j/0.1.0 63 | [010changesetprov]: https://github.com/jmchilton/blend4j/commit/d253bfc51ad8b7a9e19d1b9956d1f5ad97cfbc53 64 | [010changesetcontents1]: https://github.com/jmchilton/blend4j/commit/82717441b4d9015c38170b1231298c95630c62ee 65 | [010changesetcontents2]: https://github.com/jmchilton/blend4j/commit/76d004d59c54799fa4d10473e360158169e65b08 66 | 67 | ## [0.1-alpha-8][010alpha8release] (Apr 10, 2014) 68 | 69 | - Allow setting more [workflow parameters][010alpha8changesetworkflowparams] by steps instead of tool and allow setting multiple parameters per tool/step. 70 | - Parse more [details][010alpha8changesetworkflowdetails] during workflow detail API calls (e.g. owner, deleted, published, and step information). 71 | - Various small test fixes. 72 | 73 | [010alpha8release]: http://mvnrepository.com/artifact/com.github.jmchilton.blend4j/blend4j/0.1-alpha-8 74 | [010alpha8changesetworkflowparams]: https://github.com/jmchilton/blend4j/commit/4f9f8b710bcc715159b5d71a2691e33df77e0c25 75 | [010alpha8changesetworkflowdetails]: https://github.com/jmchilton/blend4j/commit/26d65c704292c2eb70b9500d45373277fdf5e340 76 | 77 | [apidocs]: http://jmchilton.github.io/blend4j/apidocs/ 78 | [workflowsclient]: http://jmchilton.github.io/blend4j/apidocs/com/github/jmchilton/blend4j/galaxy/WorkflowsClient.html 79 | [historiesclient]: http://jmchilton.github.io/blend4j/apidocs/com/github/jmchilton/blend4j/galaxy/HistoriesClient.html 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/galaxyproject/blend4j.png?branch=master)](https://travis-ci.org/galaxyproject/blend4j) 2 | 3 | # About 4 | 5 | blend4j is a partial reimplementation of the Python library [bioblend][1] 6 | for the JVM. bioblend for Python is a library for scripting interactions 7 | with Galaxy, CloudMan, and BioCloudCentral. 8 | 9 | [1]: https://github.com/afgane/bioblend 10 | 11 | # Usage 12 | 13 | blend4j's [JavaDocs][api] contain some quick usage examples. Many more 14 | examples can be found in [Aaron Petkau][apetkau]'s [blend4j tutorials][tutorial] 15 | and the [integration tests][tests]. Examples of using 16 | blend4j in larger open source projects include [Molgenis integration][molgensis] by [Dennis Hendriksen][dennishendriksen] and the 17 | [TraIT Workflow Runner][trait] for use with 18 | [tranSMART][transmart] by [Freek de Bruijn][freekdb]. 19 | 20 | blend4j requires Java 8+ to function. 21 | 22 | [api]: http://galaxyproject.github.io/blend4j/apidocs/ 23 | [tutorial]: https://github.com/apetkau/blend4j-tutorials 24 | [tests]: https://github.com/jmchilton/blend4j/tree/master/src/test/java/com/github/jmchilton/blend4j/galaxy 25 | [molgensis]: https://github.com/molgenis/molgenis/commit/57d229a8d36fa9dae1155685e85187399863057f 26 | [transmart]: https://github.com/transmart 27 | [trait]: https://github.com/CTMM-TraIT/trait_workflow_runner 28 | [apetkau]: https://github.com/apetkau 29 | [freekdb]: https://github.com/freekdb 30 | [dennishendriksen]: https://github.com/dennishendriksen 31 | 32 | # Building 33 | 34 | blend4j can be built with [Apache Maven][b1]. 35 | 36 | % git clone git://github.com/galaxyproject/blend4j.git 37 | % cd blend4j 38 | % mvn compile 39 | 40 | # Testing 41 | 42 | [![Build Status](https://travis-ci.org/galaxyproject/blend4j.png?branch=master)](https://travis-ci.org/galaxyproject/blend4j) 43 | 44 | blend4j can be tested with [Apache Maven][b1]. 45 | 46 | % mvn test 47 | 48 | In this default mode, blend4j will use the [galaxy-bootstrap][t1] library to download, configure, 49 | and run an instance of Galaxy for testing (requiring an Internet connection). blend4j can be tested against an existing instance using the following Java system properties. 50 | 51 | % mvn -Dtest.galaxy.key= -Dtest.galaxy.instance= test 52 | 53 | The above example will run a variety of tests and make various assumptions - some which may not be true for the supplied API key. Maven can be configured to run [a specific test or tests][t2]. 54 | 55 | [b1]: http://maven.apache.org/ 56 | [t1]: https://github.com/jmchilton/galaxy-bootstrap 57 | [t2]: http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html 58 | 59 | # Jars 60 | 61 | The easiest way to obtain blend4j is using Maven Central. 62 | 63 | For instance, if a project is using Maven, a blend4j dependency can be added by 64 | adding the following to the dependencies section of the project's pom.xml file. 65 | 66 | ```xml 67 | 68 | com.github.jmchilton.blend4j 69 | blend4j 70 | 0.2.0 71 | 72 | ``` 73 | 74 | Similar dependencies can be specified if using Ivy, Grape, Gradle, Buildr, or SBT. 75 | See [mvnrepository][d1] for more details. 76 | 77 | 78 | The latest blend4j jars can be downloaded from the [Maven Central Repository][d0]. 79 | 80 | [d0]: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.jmchilton.blend4j%22 81 | [d1]: http://mvnrepository.com/artifact/com.github.jmchilton.blend4j/blend4j/ 82 | 83 | # License 84 | 85 | The code is freely available under the [Apache License Version 2.0][l1]. 86 | 87 | [l1]: http://www.apache.org/licenses/LICENSE-2.0.html 88 | 89 | -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | read -s -p "GPG Password: " gpgpass 4 | mvn_args="-Dgpg.passphrase=$gpgpass -DskipTests=true -DperformRelease=true" 5 | 6 | mvn $mvn_args release:clean 7 | 8 | mvn $mvn_args release:prepare 9 | 10 | mvn $mvn_args release:perform 11 | 12 | echo "Artifacts staged, must be released by visiting: https://oss.sonatype.org/, closing staging repository, and then releasing." 13 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/Config.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.util.Properties; 7 | 8 | public class Config { 9 | public static Properties loadBlendProperties() { 10 | final Properties properties = new Properties(); 11 | final File blendPropertiesFile = getBlendPropertiesFile(); 12 | if(blendPropertiesFile != null) { 13 | FileInputStream fileInputStream = null; 14 | try { 15 | fileInputStream = new FileInputStream(blendPropertiesFile); 16 | properties.load(fileInputStream); 17 | } catch(IOException e) { 18 | e.printStackTrace(); 19 | } finally { 20 | try { 21 | if(fileInputStream != null) { 22 | fileInputStream.close(); 23 | } 24 | } catch(IOException e) { 25 | e.printStackTrace(); 26 | } 27 | } 28 | } 29 | return properties; 30 | } 31 | 32 | private static File getBlendPropertiesFile() { 33 | final String homeDir = System.getProperty("user.home"); 34 | File blendPropertiesFile = new File(homeDir, ".blend.properties"); 35 | if(!blendPropertiesFile.exists()) { 36 | blendPropertiesFile = null; 37 | } 38 | return blendPropertiesFile; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/exceptions/ApiException.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.exceptions; 2 | 3 | /** 4 | * Base class for all API, communication, or serialization related 5 | * exceptions in blend4j. The idea is to provide an consistent interface 6 | * and shield dependent projects from having to have explicit source code 7 | * dependencies on Jersey and Jackson. 8 | * 9 | */ 10 | public class ApiException extends RuntimeException { 11 | 12 | public ApiException() { 13 | super(); 14 | } 15 | 16 | public ApiException(final Exception exception) { 17 | super(exception); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/exceptions/ResponseException.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.exceptions; 2 | 3 | import com.github.jmchilton.blend4j.util.MoreObjects; 4 | import com.sun.jersey.api.client.ClientResponse; 5 | 6 | public class ResponseException extends ApiException { 7 | private final Integer statusCode; 8 | private final String rawResponse; 9 | 10 | public ResponseException(final ClientResponse clientResponse) { 11 | super(); 12 | this.statusCode = clientResponse.getStatus(); 13 | this.rawResponse = clientResponse.getEntity(String.class); 14 | } 15 | 16 | protected MoreObjects.ToStringHelper toStringHelper() { 17 | return MoreObjects 18 | .toStringHelper(getClass()) 19 | .add("status", statusCode) 20 | .add("responseBody", rawResponse); 21 | 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return toStringHelper().toString(); 27 | } 28 | 29 | public String getResponseBody() { 30 | return rawResponse; 31 | } 32 | 33 | public Integer getStatusCode() { 34 | return statusCode; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/exceptions/SerializationException.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.exceptions; 2 | 3 | public class SerializationException extends ApiException { 4 | 5 | public SerializationException() { 6 | } 7 | 8 | public SerializationException(Exception exception) { 9 | super(exception); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/Client.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.github.jmchilton.blend4j.BaseClient; 4 | import com.github.jmchilton.blend4j.exceptions.ResponseException; 5 | import com.github.jmchilton.blend4j.galaxy.beans.HasGalaxyUrl; 6 | import com.sun.jersey.api.client.ClientResponse; 7 | 8 | class Client extends BaseClient { 9 | private final GalaxyInstanceImpl galaxyInstance; 10 | 11 | Client(final GalaxyInstanceImpl galaxyInstance, final String module) { 12 | super(galaxyInstance.getWebResource(), module); 13 | this.galaxyInstance = galaxyInstance; 14 | } 15 | 16 | @Override 17 | protected ResponseException buildResponseException(final ClientResponse clientResponse) { 18 | final ResponseException exception = new GalaxyResponseException(clientResponse); 19 | return exception; 20 | } 21 | 22 | GalaxyInstance getGalaxyInstance() { 23 | return galaxyInstance; 24 | } 25 | 26 | protected T setGalaxyUrl(final T bean) { 27 | bean.setGalaxyUrl(galaxyInstance.getGalaxyUrl()); 28 | bean.setApiKey(galaxyInstance.getApiKey()); 29 | return bean; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/ConfigurationClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.Map; 4 | 5 | public interface ConfigurationClient { 6 | 7 | Map getRawConfiguration(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/ConfigurationClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.Map; 4 | import org.codehaus.jackson.type.TypeReference; 5 | 6 | class ConfigurationClientImpl extends Client implements ConfigurationClient { 7 | 8 | ConfigurationClientImpl(GalaxyInstanceImpl galaxyInstance) { 9 | super(galaxyInstance, "configuration"); 10 | } 11 | 12 | public Map getRawConfiguration() { 13 | final String json = getJson(getWebResource()); 14 | return readJson(json, new TypeReference>() { 15 | }); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/DefaultWebResourceFactoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.sun.jersey.api.client.WebResource; 4 | import com.sun.jersey.api.client.config.ClientConfig; 5 | import com.sun.jersey.api.client.config.DefaultClientConfig; 6 | import com.sun.jersey.api.client.filter.LoggingFilter; 7 | import com.sun.jersey.api.json.JSONConfiguration; 8 | 9 | /** 10 | * Default and simplest possible implementation of WebResourceFactory. 11 | * 12 | * @author John Chilton (jmchilton@gmail.com) 13 | * 14 | */ 15 | public class DefaultWebResourceFactoryImpl implements WebResourceFactory { 16 | private static final boolean DEBUG = false; 17 | public static String API_PATH = "api"; 18 | private String url; 19 | private String key; 20 | private boolean debug; 21 | 22 | public DefaultWebResourceFactoryImpl(final String url, final String key, final boolean debug) { 23 | this.url = url.endsWith("/") ? url.substring(0, url.length() - 1) : url; 24 | this.key = key; 25 | this.debug = debug; 26 | } 27 | 28 | public DefaultWebResourceFactoryImpl(final String url, final String key) { 29 | this(url, key, DEBUG); 30 | } 31 | 32 | /** 33 | * @return A Jersey WebResource setup to target http:///api and with the key query parameter set to 34 | * desired Galaxy key. 35 | */ 36 | public WebResource get() { 37 | final String apiKey = getApiKey(); 38 | WebResource resource = getRawWebResource(); 39 | if(apiKey != null) { 40 | resource = resource.queryParam("key", apiKey); 41 | } 42 | return resource; 43 | } 44 | 45 | public String getUrl() { 46 | return url; 47 | } 48 | 49 | @Deprecated 50 | public String getGalaxyUrl() { 51 | return getUrl(); 52 | } 53 | 54 | public String getApiKey() { 55 | return key; 56 | } 57 | 58 | /** 59 | * Return a configured Jersey client for Galaxy API code to interact with. If this method is overridden ensure 60 | * FEATURE_POJO_MAPPING is enabled. 61 | * 62 | * clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); 63 | * 64 | * @return Jersey client. 65 | * 66 | */ 67 | protected com.sun.jersey.api.client.Client getJerseyClient() { 68 | final ClientConfig clientConfig = new DefaultClientConfig(); 69 | clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); 70 | com.sun.jersey.api.client.Client client = com.sun.jersey.api.client.Client.create(clientConfig); 71 | if(this.debug) { 72 | client.addFilter(new LoggingFilter(System.out)); 73 | } 74 | return client; 75 | } 76 | 77 | /** 78 | * Build Jersey client, and get {@link WebResource} targeting Galaxy API. 79 | * Use public method get() to get higher level WebResource with key populated 80 | * for instance. 81 | * 82 | * @return Web resource corresponding to target Galaxy API. 83 | */ 84 | protected WebResource getRawWebResource() { 85 | final com.sun.jersey.api.client.Client client = getJerseyClient(); 86 | return client.resource(getUrl()).path(API_PATH); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/GalaxyAuthWebResourceFactoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.sun.jersey.api.client.ClientResponse; 4 | import com.sun.jersey.api.client.WebResource; 5 | import java.util.Map; 6 | 7 | /** 8 | * Build a WebResourceFactory from Galaxy credentials (username/password). 9 | * If Galaxy is configured to sit behind a proxy providing authentication 10 | * information - this cannot be used. 11 | * 12 | * @author John Chilton 13 | */ 14 | public class GalaxyAuthWebResourceFactoryImpl extends DefaultWebResourceFactoryImpl { 15 | private final String email; 16 | private final String password; 17 | private String key = null; 18 | 19 | public GalaxyAuthWebResourceFactoryImpl(final String url, final String email, final String password, boolean debug) { 20 | super(url, null, debug); 21 | this.email = email; 22 | this.password = password; 23 | } 24 | 25 | public GalaxyAuthWebResourceFactoryImpl(final String url, final String email, final String password) { 26 | super(url, null); 27 | this.email = email; 28 | this.password = password; 29 | } 30 | 31 | @Override 32 | public synchronized String getApiKey() { 33 | if(key == null) { 34 | final String unencodedCredentials = email + ":" + password; 35 | final String encodedCredentials = javax.xml.bind.DatatypeConverter.printBase64Binary(unencodedCredentials.getBytes()); 36 | final WebResource resource = super.getRawWebResource(); 37 | final ClientResponse response = resource.path("authenticate") 38 | .path("baseauth") 39 | .header("Authorization", encodedCredentials) 40 | .get(ClientResponse.class); 41 | if(response.getStatus() != 200) { 42 | throw new RuntimeException("Failed to build Galaxy API key for supplied user e-mail and password."); 43 | } 44 | final Map responseObjects = response.getEntity(Map.class); 45 | key = responseObjects.get("api_key").toString(); 46 | } 47 | return key; 48 | } 49 | 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/GalaxyInstance.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.sun.jersey.api.client.WebResource; 4 | 5 | public interface GalaxyInstance { 6 | HistoriesClient getHistoriesClient(); 7 | 8 | LibrariesClient getLibrariesClient(); 9 | 10 | UsersClient getUsersClient(); 11 | 12 | WorkflowsClient getWorkflowsClient(); 13 | 14 | RolesClient getRolesClient(); 15 | 16 | ToolsClient getToolsClient(); 17 | 18 | ToolDataClient getToolDataClient(); 19 | 20 | ConfigurationClient getConfigurationClient(); 21 | 22 | ToolShedRepositoriesClient getRepositoriesClient(); 23 | 24 | SearchClient getSearchClient(); 25 | 26 | WebResource getWebResource(); 27 | 28 | String getGalaxyUrl(); 29 | 30 | String getApiKey(); 31 | 32 | /** 33 | * Get a client for interacting with Galaxy's Jobs API. 34 | * 35 | * @return a jobs client for interacting with the Jobs API for this instance. 36 | */ 37 | JobsClient getJobsClient(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/GalaxyInstanceFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | 4 | /** 5 | * This class contains static factory methods for producing GalaxyInstance objects. 6 | * These objects in turn can be used to produce client's for specific Galaxy API 7 | * endpoints such as workflows and histories. 8 | * 9 | * GalaxyInstance objects can be created from a URL and API key using the {@link get} 10 | * method or from an e-mail address and password using {@link getFromCredentials}. 11 | * 12 | * Finally {@link get} can be supplied with a {@link WebResourceFactory} to control 13 | * the connection parameters at a low level - this should not be needed under normal 14 | * circumstances and requires a greater knowledge of the underlying Jersey library 15 | * to use. 16 | * 17 | * @author John Chilton 18 | */ 19 | public class GalaxyInstanceFactory { 20 | 21 | public static GalaxyInstance get(final String url, final String apiKey) { 22 | return get(new DefaultWebResourceFactoryImpl(url, apiKey)); 23 | } 24 | 25 | public static GalaxyInstance get(final String url, final String apiKey, final boolean debug) { 26 | return get(new DefaultWebResourceFactoryImpl(url, apiKey, debug)); 27 | } 28 | 29 | public static GalaxyInstance getFromCredentials(final String url, final String email, final String password) { 30 | return get(new GalaxyAuthWebResourceFactoryImpl(url, email, password)); 31 | } 32 | 33 | public static GalaxyInstance getFromCredentials(final String url, final String email, final String password, final boolean debug) { 34 | return get(new GalaxyAuthWebResourceFactoryImpl(url, email, password, debug)); 35 | } 36 | 37 | public static GalaxyInstance get(final WebResourceFactory webResourceFactory) { 38 | return new GalaxyInstanceImpl(webResourceFactory); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/GalaxyInstanceImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.sun.jersey.api.client.WebResource; 4 | 5 | class GalaxyInstanceImpl implements GalaxyInstance { 6 | private final WebResourceFactory webResourceFactory; 7 | 8 | GalaxyInstanceImpl(final WebResourceFactory webResourceFactory) { 9 | this.webResourceFactory = webResourceFactory; 10 | } 11 | 12 | public ToolShedRepositoriesClient getRepositoriesClient() { 13 | return new ToolShedRepositoriesClientImpl(this); 14 | } 15 | 16 | public HistoriesClient getHistoriesClient() { 17 | return new HistoriesClientImpl(this); 18 | } 19 | 20 | public LibrariesClient getLibrariesClient() { 21 | return new LibrariesClientImpl(this); 22 | } 23 | 24 | public UsersClient getUsersClient() { 25 | return new UsersClientImpl(this); 26 | } 27 | 28 | public WorkflowsClient getWorkflowsClient() { 29 | return new WorkflowsClientImpl(this); 30 | } 31 | 32 | public RolesClient getRolesClient() { 33 | return new RolesClientImpl(this); 34 | } 35 | 36 | public ToolsClient getToolsClient() { 37 | return new ToolsClientImpl(this); 38 | } 39 | 40 | public ToolDataClient getToolDataClient() { 41 | return new ToolDataClientImpl(this); 42 | } 43 | 44 | public ConfigurationClient getConfigurationClient() { 45 | return new ConfigurationClientImpl(this); 46 | } 47 | 48 | public SearchClient getSearchClient() { 49 | return new SearchClientImpl(this); 50 | } 51 | 52 | public WebResource getWebResource() { 53 | return webResourceFactory.get(); 54 | } 55 | 56 | public String getGalaxyUrl() { 57 | return webResourceFactory.getGalaxyUrl(); 58 | } 59 | 60 | public String getApiKey() { 61 | return webResourceFactory.getApiKey(); 62 | } 63 | 64 | /** 65 | * {@inheritDoc} 66 | */ 67 | public JobsClient getJobsClient() { 68 | return new JobsClientImpl(this); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/GalaxyResponseException.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.github.jmchilton.blend4j.exceptions.ResponseException; 4 | import com.github.jmchilton.blend4j.util.MoreObjects; 5 | import com.sun.jersey.api.client.ClientResponse; 6 | import java.io.IOException; 7 | import java.util.Map; 8 | import org.codehaus.jackson.map.ObjectMapper; 9 | import org.codehaus.jackson.type.TypeReference; 10 | 11 | public class GalaxyResponseException extends ResponseException { 12 | private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); 13 | private static final TypeReference> ERROR_MAP = new TypeReference>() { 14 | }; 15 | public static final String DEFAULT_ERROR_MESSAGE = null; 16 | public static final Integer DEFAULT_ERROR_CODE = null; 17 | public static final String DEFAULT_TRACEBACK = null; 18 | 19 | private String errorMessage = DEFAULT_ERROR_MESSAGE; 20 | private Integer errorCode = DEFAULT_ERROR_CODE; 21 | private String traceback = DEFAULT_TRACEBACK; 22 | 23 | public GalaxyResponseException(ClientResponse clientResponse) { 24 | super(clientResponse); 25 | try { 26 | final Map errorMap = OBJECT_MAPPER.readValue(getResponseBody(), ERROR_MAP); 27 | if(errorMap.containsKey("err_msg")) { 28 | errorMessage = errorMap.get("err_msg"); 29 | } 30 | if(errorMap.containsKey("err_code")) { 31 | try { 32 | errorCode = Integer.parseInt(errorMap.get("err_code")); 33 | } catch(NumberFormatException exception) { 34 | } 35 | } 36 | if(errorMap.containsKey("traceback")) { 37 | traceback = errorMap.get("traceback"); 38 | } 39 | } catch(final RuntimeException exception) { 40 | } catch(final IOException exception) { 41 | // Not all Galaxy behave well - many still don't return JSON responses, 42 | // that is most likely what happened here. 43 | } 44 | } 45 | 46 | protected MoreObjects.ToStringHelper toStringHelper() { 47 | return super.toStringHelper() 48 | .add("errorMessage", errorMessage) 49 | .add("errorCode", errorCode) 50 | .add("traceback", traceback); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/HistoriesClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.List; 6 | 7 | import com.github.jmchilton.blend4j.galaxy.beans.Dataset; 8 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryDeleteResponse; 9 | import com.github.jmchilton.blend4j.galaxy.beans.History; 10 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails; 11 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryContents; 12 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance; 13 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset; 14 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryExport; 15 | import com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription; 16 | import com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse; 17 | import com.sun.jersey.api.client.ClientResponse; 18 | 19 | public interface HistoriesClient { 20 | ClientResponse createRequest(final History history); 21 | 22 | History create(History history); 23 | 24 | List getHistories(); 25 | 26 | ClientResponse showHistoryRequest(String historyId); 27 | 28 | HistoryDetails showHistory(String historyId); 29 | 30 | List showHistoryContents(String historyId); 31 | 32 | HistoryDetails createHistoryDataset(String historyId, HistoryDataset hd); 33 | 34 | Dataset showDataset(String historyId, String datasetId); 35 | 36 | HistoryContentsProvenance showProvenance(String historyId, String datasetId); 37 | 38 | HistoryExport exportHistory(String historyId); 39 | 40 | /** 41 | * Deletes the given History from Galaxy (this will not purge). This will 42 | * return a {@link ClientResponse} object providing access to the status code 43 | * and the non-serialized body of the response. 44 | * 45 | * @param historyId 46 | * The id of the History to delete. 47 | * @return A {@link ClientResponse} for this request. The status code provided 48 | * by {@link ClientResponse#getClientResponseStatus()} should be 49 | * verified for success. 50 | */ 51 | ClientResponse deleteHistoryRequest(String historyId); 52 | 53 | /** 54 | * Deletes the given History from Galaxy (this will not purge). This will 55 | * return a {@link HistoryDeleteResponse} object for the delete request with 56 | * information provided by Galaxy. 57 | * 58 | * @param historyId 59 | * The id of the History to delete. 60 | * @return A {@link HistoryDeleteResponse} for this request. 61 | */ 62 | HistoryDeleteResponse deleteHistory(String historyId); 63 | 64 | /** 65 | * Gets a Dataset collection for the given historyId and datasetCollectionId. 66 | * @param historyId The ID of the history to search for dataset collections. 67 | * @param datasetCollectionId The id of the dataset collection to search for. 68 | * @return A DatasetCollection from the passed ids. 69 | */ 70 | CollectionResponse showDatasetCollection(String historyId, String datasetCollectionId); 71 | 72 | /** 73 | * Creates a new Dataset Collection from the given information. 74 | * @param historyId The history to store this dataset collection. 75 | * @param collectionDescription A CollectionDescription describing the dataset collection to create. 76 | * @return A ClientResponse describing the response. 77 | */ 78 | ClientResponse createDatasetCollectionRequest(String historyId, 79 | CollectionDescription collectionDescription); 80 | 81 | /** 82 | * Creates a new Dataset Collection from the given information. 83 | * @param historyId The history to store this dataset collection. 84 | * @param collectionDescription A CollectionDescription describing the dataset collection to create. 85 | * @return A DatasetCollection describing the created dataset collection. 86 | */ 87 | CollectionResponse createDatasetCollection(String historyId, 88 | CollectionDescription collectionDescription); 89 | 90 | /** 91 | * Downloads the dataset within the given history to the passed file. 92 | * @param historyId The id of the history containing the dataset. 93 | * @param datasetId The id of the dataset to download. 94 | * @param destinationFile The location to store the downloaded dataset. 95 | * @throws IOException If there was an issue writing to the destination file. 96 | */ 97 | void downloadDataset(String historyId, String datasetId, File destinationFile) throws IOException; 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/HistoriesClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.io.File; 4 | import java.io.FileWriter; 5 | import java.io.IOException; 6 | import java.util.List; 7 | 8 | import org.codehaus.jackson.type.TypeReference; 9 | 10 | import com.github.jmchilton.blend4j.galaxy.beans.Dataset; 11 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryDeleteResponse; 12 | import com.github.jmchilton.blend4j.galaxy.beans.History; 13 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails; 14 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryContents; 15 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance; 16 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset; 17 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryExport; 18 | import com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription; 19 | import com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse; 20 | import com.sun.jersey.api.client.ClientResponse; 21 | import com.sun.jersey.api.client.WebResource; 22 | 23 | import javax.ws.rs.core.MediaType; 24 | 25 | class HistoriesClientImpl extends Client implements HistoriesClient { 26 | HistoriesClientImpl(GalaxyInstanceImpl galaxyInstance) { 27 | super(galaxyInstance, "histories"); 28 | } 29 | 30 | public ClientResponse createRequest(final History history) { 31 | return super.create(history); 32 | } 33 | 34 | public History create(final History history) { 35 | return createRequest(history).getEntity(History.class); 36 | } 37 | 38 | public List getHistories() { 39 | final TypeReference> typeReference = new TypeReference>() { 40 | }; 41 | return get(typeReference); 42 | } 43 | 44 | public ClientResponse showHistoryRequest(String id) { 45 | return super.show(id, ClientResponse.class); 46 | } 47 | 48 | public HistoryDetails showHistory(String id) { 49 | return super.show(id, HistoryDetails.class); 50 | } 51 | 52 | public List showHistoryContents(String historyId) { 53 | return get(getWebResourceContents(historyId), new TypeReference>() { 54 | }); 55 | } 56 | 57 | public Dataset showDataset(String historyId, String datasetId) { 58 | return setGalaxyUrl(getWebResourceContents(historyId).path(datasetId).get(Dataset.class)); 59 | } 60 | 61 | public HistoryContentsProvenance showProvenance(String historyId, String datasetId) { 62 | return getWebResourceContents(historyId).path(datasetId).path("provenance").get(HistoryContentsProvenance.class); 63 | } 64 | 65 | 66 | public HistoryDetails createHistoryDataset(String historyId, HistoryDataset hd) { 67 | final ClientResponse response = super.create(super.path(historyId).path("contents"), hd); 68 | return response.getEntity(HistoryDetails.class); 69 | } 70 | 71 | public HistoryExport exportHistory(String historyId) { 72 | final WebResource.Builder resource = super.path(historyId).path("exports").type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON); 73 | final ClientResponse response = resource.put(ClientResponse.class); 74 | final int status = response.getStatus(); 75 | if(status == 200) { 76 | return response.getEntity(HistoryExport.class); 77 | } else if(status == 202) { 78 | return new HistoryExport(); 79 | } else { 80 | throw new RuntimeException("Problems with history export."); 81 | } 82 | } 83 | 84 | @Override 85 | public CollectionResponse showDatasetCollection(String historyId, 86 | String datasetCollectionId) { 87 | return getWebResourceContents(historyId).path("dataset_collections"). 88 | path(datasetCollectionId).get(CollectionResponse.class); 89 | } 90 | 91 | @Override 92 | public ClientResponse createDatasetCollectionRequest(String historyId, 93 | CollectionDescription collectionDescription) { 94 | final ClientResponse response = super.create(super.path(historyId).path("contents"), collectionDescription); 95 | return response; 96 | } 97 | 98 | @Override 99 | public CollectionResponse createDatasetCollection(String historyId, 100 | CollectionDescription collectionDescription) { 101 | ClientResponse response = createDatasetCollectionRequest(historyId, collectionDescription); 102 | 103 | if (response.getStatus() == 200) { 104 | return response.getEntity(CollectionResponse.class); 105 | } else { 106 | throw new RuntimeException("Error creating dataset collection, status=" + response.getStatus() + 107 | " returned=" + response.getEntity(String.class)); 108 | } 109 | } 110 | 111 | @Override 112 | public void downloadDataset(String historyId, String datasetId, 113 | File destinationFile) throws IOException { 114 | Dataset dataset = showDataset(historyId, datasetId); 115 | String fileExt = dataset.getDataTypeExt(); 116 | 117 | File downloadedFile = super.getWebResourceContents(historyId) 118 | .path(datasetId).path("display").queryParam("to_ext", fileExt) 119 | .get(File.class); 120 | downloadedFile.renameTo(destinationFile); 121 | FileWriter fr = new FileWriter(downloadedFile); 122 | fr.close(); 123 | } 124 | 125 | @Override 126 | public ClientResponse deleteHistoryRequest(String historyId) { 127 | return deleteResponse(getWebResource(historyId)); 128 | } 129 | 130 | @Override 131 | public HistoryDeleteResponse deleteHistory(String historyId) { 132 | return deleteHistoryRequest(historyId).getEntity(HistoryDeleteResponse.class); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/JobsClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.List; 4 | 5 | import com.github.jmchilton.blend4j.galaxy.beans.Job; 6 | import com.github.jmchilton.blend4j.galaxy.beans.JobDetails; 7 | 8 | /** 9 | * Client for interacting with Galaxy's Job API. 10 | * 11 | * @author Franklin Bristow franklin.bristow@phac-aspc.gc.ca 12 | * 13 | */ 14 | public interface JobsClient { 15 | 16 | /** 17 | * Get *all* jobs executed by Galaxy. **WARNING**: This may take a long time 18 | * to execute, depending on how many jobs Galaxy has executed in its 19 | * history. 20 | * 21 | * @return a collection of all jobs executed by Galaxy. 22 | */ 23 | public List getJobs(); 24 | 25 | /** 26 | * Get all jobs executed by Galaxy for a specific history. 27 | * 28 | * @param historyId 29 | * the history id to load jobs for. 30 | * @return the collection of jobs corresponding to the history. 31 | */ 32 | public List getJobsForHistory(final String historyId); 33 | 34 | /** 35 | * Show the details of a specific job execution. 36 | * 37 | * @param id 38 | * the job id 39 | * @return the details of a job. 40 | */ 41 | public JobDetails showJob(final String id); 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/JobsClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.List; 4 | 5 | import org.codehaus.jackson.type.TypeReference; 6 | 7 | import com.github.jmchilton.blend4j.galaxy.beans.Job; 8 | import com.github.jmchilton.blend4j.galaxy.beans.JobDetails; 9 | 10 | /** 11 | * Implementation for interacting with Galaxy's Job API. 12 | * 13 | * @author Franklin Bristow franklin.bristow@phac-aspc.gc.ca 14 | * 15 | */ 16 | public class JobsClientImpl extends Client implements JobsClient { 17 | 18 | JobsClientImpl(GalaxyInstanceImpl galaxyInstance) { 19 | super(galaxyInstance, "jobs"); 20 | } 21 | 22 | /** 23 | * {@inheritDoc} 24 | */ 25 | @Override 26 | public List getJobs() { 27 | return get(new TypeReference>() { 28 | }); 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | @Override 35 | public JobDetails showJob(final String id) { 36 | return super.show(id, JobDetails.class); 37 | } 38 | 39 | /** 40 | * {@inheritDoc} 41 | */ 42 | public List getJobsForHistory(String historyId) { 43 | return get(getWebResource().queryParam("history_id", historyId), new TypeReference>() { 44 | }); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/LibrariesClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.List; 4 | 5 | import com.github.jmchilton.blend4j.galaxy.beans.DirectoryLibraryUpload; 6 | import com.github.jmchilton.blend4j.galaxy.beans.FileLibraryUpload; 7 | import com.github.jmchilton.blend4j.galaxy.beans.FilesystemPathsLibraryUpload; 8 | import com.github.jmchilton.blend4j.galaxy.beans.GalaxyObject; 9 | import com.github.jmchilton.blend4j.galaxy.beans.Library; 10 | import com.github.jmchilton.blend4j.galaxy.beans.LibraryContent; 11 | import com.github.jmchilton.blend4j.galaxy.beans.LibraryDataset; 12 | import com.github.jmchilton.blend4j.galaxy.beans.LibraryFolder; 13 | import com.github.jmchilton.blend4j.galaxy.beans.LibraryPermissions; 14 | import com.github.jmchilton.blend4j.galaxy.beans.UrlLibraryUpload; 15 | import com.sun.jersey.api.client.ClientResponse; 16 | 17 | public interface LibrariesClient { 18 | ClientResponse createLibraryRequest(Library library); 19 | 20 | Library createLibrary(Library library); 21 | 22 | List getLibraries(); 23 | 24 | ClientResponse createFolderRequest(String libraryId, LibraryFolder libraryFolder); 25 | 26 | LibraryFolder createFolder(String libraryId, LibraryFolder libraryFolder); 27 | 28 | ClientResponse uploadFileFromUrlRequest(String libraryId, UrlLibraryUpload upload); 29 | 30 | ClientResponse uploadServerDirectoryRequest(String libraryId, DirectoryLibraryUpload upload); 31 | 32 | ClientResponse uploadFilesystemPathsRequest(String libraryId, FilesystemPathsLibraryUpload upload); 33 | 34 | /** 35 | * Uploads a file from a local filesystem path to a library. 36 | * @param libraryId The Library to upload the file to. 37 | * @param upload The object representing an upload request. 38 | * @return A GalaxyObject representing the response for this upload. 39 | */ 40 | GalaxyObject uploadFilesystemPaths(final String libraryId, final FilesystemPathsLibraryUpload upload); 41 | 42 | ClientResponse uploadFile(String libraryId, FileLibraryUpload upload); 43 | 44 | LibraryContent getRootFolder(String libraryId); 45 | 46 | List getLibraryContents(String libraryId); 47 | 48 | ClientResponse uploadFileFromUrl(String libraryId, FilesystemPathsLibraryUpload upload); 49 | 50 | ClientResponse setLibraryPermissions(String libraryId, LibraryPermissions permissions); 51 | 52 | /** 53 | * Gets a ClientResponse object for a request to show details on a dataset within a Library. 54 | * @param libraryId The id of the Library the dataset is located within. 55 | * @param datasetId The id of the dataset to get details. 56 | * @return A {@link ClientResponse} object representing details on the showDatasets request. 57 | */ 58 | ClientResponse showDatasetRequest(String libraryId, String datasetId); 59 | 60 | /** 61 | * Gets details about a given library dataset. 62 | * @param libraryId The id of the Library the dataset is located within. 63 | * @param datasetId The id of the dataset to get details. 64 | * @return A {@link LibraryDataset} object representing details for this dataset. 65 | */ 66 | LibraryDataset showDataset(String libraryId, String datasetId); 67 | 68 | /** 69 | * Deletes the given library from Galaxy (this is irreversible). This will return a 70 | * {@link ClientResponse} object providing access to the status code and the 71 | * non-serialized body of the response. 72 | * 73 | * @param libraryId 74 | * The id of the library to delete. 75 | * @return A {@link ClientResponse} for the deleted library. The status code 76 | * provided by {@link ClientResponse#getClientResponseStatus()} should 77 | * be verified for success. 78 | */ 79 | ClientResponse deleteLibraryRequest(String libraryId); 80 | } -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/LibrariesClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.List; 4 | 5 | import org.codehaus.jackson.type.TypeReference; 6 | 7 | import com.github.jmchilton.blend4j.galaxy.beans.DirectoryLibraryUpload; 8 | import com.github.jmchilton.blend4j.galaxy.beans.FileLibraryUpload; 9 | import com.github.jmchilton.blend4j.galaxy.beans.FilesystemPathsLibraryUpload; 10 | import com.github.jmchilton.blend4j.galaxy.beans.GalaxyObject; 11 | import com.github.jmchilton.blend4j.galaxy.beans.Library; 12 | import com.github.jmchilton.blend4j.galaxy.beans.LibraryContent; 13 | import com.github.jmchilton.blend4j.galaxy.beans.LibraryDataset; 14 | import com.github.jmchilton.blend4j.galaxy.beans.LibraryFolder; 15 | import com.github.jmchilton.blend4j.galaxy.beans.LibraryPermissions; 16 | import com.github.jmchilton.blend4j.galaxy.beans.UrlLibraryUpload; 17 | import com.sun.jersey.api.client.ClientResponse; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | class LibrariesClientImpl extends Client implements LibrariesClient { 23 | LibrariesClientImpl(GalaxyInstanceImpl galaxyInstance) { 24 | super(galaxyInstance, "libraries"); 25 | } 26 | 27 | public ClientResponse createLibraryRequest(final Library library) { 28 | return super.create(library); 29 | } 30 | 31 | public Library createLibrary(final Library library) { 32 | // should not be this complicated, I suspect library API is returning wrong thing. See galaxy issue #802 33 | return createLibraryRequest(library).getEntity(Library.class); 34 | //return readJson(createLibraryRequest(library).getEntity(String.class), new TypeReference>() {}).get(0); 35 | } 36 | 37 | public ClientResponse createFolderRequest(final String libraryId, final LibraryFolder folder) { 38 | final String baseFolderId = folder.getFolderId(); 39 | if(baseFolderId == null) { 40 | throw new IllegalArgumentException("Must specify parent folder id"); 41 | } 42 | return super.create(getWebResourceContents(libraryId), folder); 43 | } 44 | 45 | 46 | public LibraryFolder createFolder(final String libraryId, final LibraryFolder folder) { 47 | return readJson(createFolderRequest(libraryId, folder).getEntity(String.class), new TypeReference>() {}).get(0); 48 | } 49 | 50 | public List getLibraries() { 51 | return get(new TypeReference>() { 52 | }); 53 | } 54 | 55 | public ClientResponse uploadFileFromUrlRequest(final String libraryId, final UrlLibraryUpload upload) { 56 | return super.create(getWebResourceContents(libraryId), upload); 57 | } 58 | 59 | public ClientResponse uploadServerDirectoryRequest(final String libraryId, final DirectoryLibraryUpload upload) { 60 | return super.create(getWebResourceContents(libraryId), upload); 61 | } 62 | 63 | public ClientResponse uploadFilesystemPathsRequest(final String libraryId, final FilesystemPathsLibraryUpload upload) { 64 | return super.create(getWebResourceContents(libraryId), upload); 65 | } 66 | 67 | public GalaxyObject uploadFilesystemPaths(final String libraryId, final FilesystemPathsLibraryUpload upload) { 68 | return readJson(uploadFilesystemPathsRequest(libraryId, upload).getEntity(String.class), new TypeReference>() {}).get(0); 69 | } 70 | 71 | public LibraryContent getRootFolder(final String libraryId) { 72 | final List libraryContents = getLibraryContents(libraryId); 73 | LibraryContent rootFolder = null; 74 | for(final LibraryContent content : libraryContents) { 75 | if("/".equals(content.getName())) { 76 | rootFolder = content; 77 | break; 78 | } 79 | } 80 | return rootFolder; 81 | } 82 | 83 | public List getLibraryContents(final String libraryId) { 84 | return get(getWebResourceContents(libraryId), new TypeReference>() { 85 | }); 86 | } 87 | 88 | public ClientResponse uploadFileFromUrl(final String libraryId, final FilesystemPathsLibraryUpload upload) { 89 | return super.create(getWebResourceContents(libraryId), upload); 90 | } 91 | 92 | public ClientResponse setLibraryPermissions(String libraryId, LibraryPermissions permissions) { 93 | final String payload = write(permissions); 94 | return super.create(getWebResource(libraryId).path("permissions"), payload); 95 | } 96 | 97 | public ClientResponse uploadFile(String libraryId, FileLibraryUpload upload) { 98 | final Map entityMap = new HashMap(); 99 | entityMap.put("file_type", upload.getFileType()); 100 | entityMap.put("db_key", upload.getDbkey()); 101 | entityMap.put("files_0|NAME", upload.getName()); 102 | entityMap.put("upload_option", upload.getUploadOption()); 103 | entityMap.put("folder_id", upload.getFolderId()); 104 | entityMap.put("create_type", upload.getCreateType()); 105 | return super.multipartPost(getWebResourceContents(libraryId), entityMap, prepareUpload(upload.getFile())); 106 | } 107 | 108 | @Override 109 | public ClientResponse showDatasetRequest(String libraryId, String datasetId) { 110 | return getResponse(getWebResourceContents(libraryId).path(datasetId)); 111 | } 112 | 113 | @Override 114 | public LibraryDataset showDataset(String libraryId, String datasetId) { 115 | return read(showDatasetRequest(libraryId, datasetId), LibraryDataset.class); 116 | } 117 | 118 | @Override 119 | public ClientResponse deleteLibraryRequest(String libraryId) { 120 | return deleteResponse(getWebResource(libraryId)); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/RolesClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.List; 4 | 5 | import com.github.jmchilton.blend4j.galaxy.beans.Role; 6 | 7 | public interface RolesClient { 8 | List getRoles(); 9 | 10 | Role getRole(final String name); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/RolesClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.List; 4 | 5 | import org.codehaus.jackson.type.TypeReference; 6 | 7 | import com.github.jmchilton.blend4j.galaxy.beans.Role; 8 | 9 | class RolesClientImpl extends Client implements RolesClient { 10 | private static final TypeReference> ROLE_LIST_TYPE_REFERENCE = new TypeReference>() { 11 | }; 12 | 13 | RolesClientImpl(GalaxyInstanceImpl galaxyInstance) { 14 | super(galaxyInstance, "roles"); 15 | } 16 | 17 | public List getRoles() { 18 | return super.get(ROLE_LIST_TYPE_REFERENCE); 19 | } 20 | 21 | public Role getRole(final String name) { 22 | Role matchingRole = null; 23 | for(final Role role : getRoles()) { 24 | if(role.getName().equals(name)) { 25 | matchingRole = role; 26 | } 27 | } 28 | return matchingRole; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/SearchClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | public interface SearchClient { 7 | 8 | public class SearchResponse { 9 | private List> results; 10 | 11 | public List> getResults() { 12 | return results; 13 | } 14 | 15 | public void setResults(List> results) { 16 | this.results = results; 17 | } 18 | 19 | } 20 | 21 | public SearchResponse search(final String searchQuery); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/SearchClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.sun.jersey.api.client.ClientResponse; 4 | import java.util.HashMap; 5 | 6 | public class SearchClientImpl extends Client implements SearchClient { 7 | 8 | SearchClientImpl(GalaxyInstanceImpl galaxyInstance) { 9 | super(galaxyInstance, "search"); 10 | } 11 | 12 | public SearchResponse search(String searchQuery) { 13 | final HashMap postObject = new HashMap(); 14 | postObject.put("query", searchQuery); 15 | final ClientResponse response = super.create(postObject); 16 | return response.getEntity(SearchResponse.class); 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/SslHacking.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import javax.net.ssl.HostnameVerifier; 4 | import javax.net.ssl.HttpsURLConnection; 5 | import javax.net.ssl.SSLContext; 6 | import javax.net.ssl.SSLSession; 7 | 8 | public class SslHacking { 9 | public static void disableCertificateCheck() { 10 | javax.net.ssl.TrustManager x509 = new javax.net.ssl.X509TrustManager() { 11 | public void checkClientTrusted(java.security.cert.X509Certificate[] arg0, String arg1) throws java.security.cert.CertificateException { 12 | return; 13 | } 14 | 15 | public void checkServerTrusted(java.security.cert.X509Certificate[] arg0, String arg1) throws java.security.cert.CertificateException { 16 | return; 17 | } 18 | 19 | public java.security.cert.X509Certificate[] getAcceptedIssuers() { 20 | return null; 21 | } 22 | }; 23 | SSLContext ctx = null; 24 | try { 25 | ctx = SSLContext.getInstance("SSL"); 26 | ctx.init(null, new javax.net.ssl.TrustManager[] {x509}, null); 27 | } catch(java.security.GeneralSecurityException ex) { 28 | } 29 | 30 | 31 | // Create all-trusting host name verifier 32 | HostnameVerifier allHostsValid = new HostnameVerifier() { 33 | public boolean verify(String hostname, SSLSession session) { 34 | return true; 35 | } 36 | }; 37 | // Install the all-trusting host verifier 38 | HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); 39 | HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/ToolDataClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.beans.TabularToolDataTable; 4 | import com.sun.jersey.api.client.ClientResponse; 5 | 6 | import java.util.List; 7 | 8 | public interface ToolDataClient { 9 | ClientResponse showDataTableRequest(String dataTableId); 10 | 11 | /** 12 | * Delete an item from a data table. 13 | * @param dataTableId ID of the data table 14 | * @param values list of column contents, there must be a value for all the columns of the data table 15 | * @return A {@link ClientResponse} for the deleted tool data table items. The status code 16 | * provided by {@link ClientResponse#getClientResponseStatus()} should 17 | * be verified for success. 18 | */ 19 | ClientResponse deleteDataTableRequest(final String dataTableId, final List values); 20 | 21 | /** 22 | * Get a list of all Tool Data Tables stored in Galaxy. 23 | * 24 | * @return the list of Tool Data Tables installed in Galaxy. 25 | */ 26 | List getDataTables(); 27 | 28 | /** 29 | * Show details about the specified tool. 30 | * 31 | * @param dataTableId the Tool Data Table to look up. 32 | * @return updated details about the Tool Data Table. 33 | */ 34 | // TabularToolDataTable reloadDataTable(final String dataTableId); 35 | 36 | /** 37 | * Show details about the specified tool. 38 | * 39 | * @param dataTableId the Tool Data Table to look up. 40 | * @return A {@link ClientResponse} for the reloaded tool data table. The status code 41 | * provided by {@link ClientResponse#getClientResponseStatus()} should 42 | * be verified for success. 43 | */ 44 | ClientResponse reloadDataTableRequest(final String dataTableId); 45 | 46 | /** 47 | * Show details about the specified tool. 48 | * 49 | * @param dataTableId the Tool Data Table to look up. 50 | * @return details about the Tool Data Table. 51 | */ 52 | TabularToolDataTable showDataTable(final String dataTableId); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/ToolDataClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.beans.TabularToolDataTable; 4 | import com.sun.jersey.api.client.ClientResponse; 5 | import org.codehaus.jackson.type.TypeReference; 6 | 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public class ToolDataClientImpl extends Client implements ToolDataClient { 12 | 13 | ToolDataClientImpl(GalaxyInstanceImpl galaxyInstance) { 14 | super(galaxyInstance, "tool_data"); 15 | } 16 | 17 | public ClientResponse showDataTableRequest(String dataTableId) { 18 | return super.show(dataTableId, ClientResponse.class); 19 | } 20 | 21 | public ClientResponse deleteDataTableRequest(final String dataTableId, final List values) { 22 | Map requestEntity = new HashMap(); 23 | requestEntity.put("values", String.join("\t", values)); 24 | return deleteResponse(getWebResource(dataTableId), requestEntity); 25 | } 26 | 27 | public List getDataTables() { 28 | return get(new TypeReference>() {}); 29 | } 30 | 31 | public ClientResponse reloadDataTableRequest(final String dataTableId) { 32 | return getResponse(getWebResource(dataTableId).path("reload")); 33 | } 34 | 35 | public TabularToolDataTable showDataTable(final String dataTableId) { 36 | return super.show(dataTableId, TabularToolDataTable.class); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/ToolShedRepositoriesClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.beans.InstallableRepositoryRevision; 4 | import com.github.jmchilton.blend4j.galaxy.beans.InstalledRepository; 5 | import com.github.jmchilton.blend4j.galaxy.beans.RepositoryInstall; 6 | import com.github.jmchilton.blend4j.galaxy.beans.RepositoryWorkflow; 7 | import com.github.jmchilton.blend4j.galaxy.beans.Workflow; 8 | import com.sun.jersey.api.client.ClientResponse; 9 | import java.util.List; 10 | 11 | public interface ToolShedRepositoriesClient { 12 | 13 | List getRepositories(); 14 | 15 | InstalledRepository showRepository(String toolShedId); 16 | 17 | ClientResponse installRepositoryRequest(RepositoryInstall install); 18 | 19 | List installRepository(final RepositoryInstall install); 20 | 21 | ClientResponse repairRepositoryRequest(InstallableRepositoryRevision repositoryIdentifier); 22 | 23 | ClientResponse exportedWorkflowsRequest(String toolShedId); 24 | 25 | List exportedWorkflows(String toolShedId); 26 | 27 | ClientResponse importWorkflowRequest(String toolShedId, int index); 28 | 29 | Workflow importWorkflow(String toolShedId, int index); 30 | 31 | ClientResponse importWorkflowsRequest(String toolShedId); 32 | 33 | List importWorkflows(String toolShedId); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/ToolShedRepositoriesClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.beans.InstallableRepositoryRevision; 4 | import com.github.jmchilton.blend4j.galaxy.beans.InstalledRepository; 5 | import com.github.jmchilton.blend4j.galaxy.beans.RepositoryInstall; 6 | import com.github.jmchilton.blend4j.galaxy.beans.RepositoryWorkflow; 7 | import com.github.jmchilton.blend4j.galaxy.beans.Workflow; 8 | import com.sun.jersey.api.client.ClientResponse; 9 | import com.sun.jersey.api.client.WebResource; 10 | import java.util.HashMap; 11 | import java.util.List; 12 | import org.codehaus.jackson.type.TypeReference; 13 | 14 | class ToolShedRepositoriesClientImpl extends Client implements ToolShedRepositoriesClient { 15 | private static final TypeReference> TOOL_SHED_REPOSITORY_LIST_TYPE_REFERENCE = new TypeReference>() { 16 | }; 17 | private static final TypeReference> TOOL_SHED_REPOSITORY_WORKFLOW_LIST_TYPE_REFERENCE = 18 | new TypeReference>() { 19 | }; 20 | private static final TypeReference> WORKFLOW_LIST_TYPE_REFERENCE = 21 | new TypeReference>() { 22 | }; 23 | 24 | 25 | ToolShedRepositoriesClientImpl(GalaxyInstanceImpl galaxyInstance) { 26 | super(galaxyInstance, "tool_shed_repositories"); 27 | } 28 | 29 | public List getRepositories() { 30 | return super.get(TOOL_SHED_REPOSITORY_LIST_TYPE_REFERENCE); 31 | } 32 | 33 | public InstalledRepository showRepository(final String toolShedId) { 34 | return super.show(toolShedId, InstalledRepository.class); 35 | } 36 | 37 | public ClientResponse installRepositoryRequest(final RepositoryInstall install) { 38 | final WebResource resource = super.webResource.path("new").path("install_repository_revision"); 39 | return super.create(resource, install); 40 | } 41 | 42 | public List installRepository(final RepositoryInstall install) { 43 | final ClientResponse response = this.installRepositoryRequest(install); 44 | return super.read(response, TOOL_SHED_REPOSITORY_LIST_TYPE_REFERENCE); 45 | } 46 | 47 | public ClientResponse repairRepositoryRequest(final InstallableRepositoryRevision repositoryIdentifier) { 48 | final WebResource resource = super.webResource.path("repair_repository_revision"); 49 | return super.create(resource, repositoryIdentifier); 50 | } 51 | 52 | public ClientResponse exportedWorkflowsRequest(String toolShedId) { 53 | final WebResource resource = super.webResource.path(toolShedId).path("exported_workflows"); 54 | return resource.get(ClientResponse.class); 55 | } 56 | 57 | public List exportedWorkflows(String toolShedId) { 58 | return super.read(this.exportedWorkflowsRequest(toolShedId), 59 | TOOL_SHED_REPOSITORY_WORKFLOW_LIST_TYPE_REFERENCE); 60 | } 61 | 62 | public ClientResponse importWorkflowRequest(String toolShedId, int index) { 63 | final WebResource resource = super.webResource.path(toolShedId).path("import_workflow"); 64 | final HashMap postObject = new HashMap(); 65 | postObject.put("index", index); 66 | return super.create(resource, postObject); 67 | } 68 | 69 | public Workflow importWorkflow(String toolShedId, int index) { 70 | final ClientResponse response = this.importWorkflowRequest(toolShedId, index); 71 | return response.getEntity(Workflow.class); 72 | } 73 | 74 | public ClientResponse importWorkflowsRequest(String toolShedId) { 75 | final WebResource resource = super.webResource.path(toolShedId).path("import_workflows"); 76 | return super.create(resource); 77 | } 78 | 79 | public List importWorkflows(String toolShedId) { 80 | return read(importWorkflowsRequest(toolShedId), WORKFLOW_LIST_TYPE_REFERENCE); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/ToolsClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.io.File; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import com.github.jmchilton.blend4j.galaxy.beans.History; 11 | import com.github.jmchilton.blend4j.galaxy.beans.Tool; 12 | import com.github.jmchilton.blend4j.galaxy.beans.ToolExecution; 13 | import com.github.jmchilton.blend4j.galaxy.beans.ToolInputs; 14 | import com.github.jmchilton.blend4j.galaxy.beans.ToolSection; 15 | import com.sun.jersey.api.client.ClientResponse; 16 | 17 | public interface ToolsClient { 18 | ToolExecution create(History history, ToolInputs inputs); 19 | 20 | /** 21 | * 22 | * @deprecated Use {@link uploadRequest} now. 23 | * 24 | */ 25 | @Deprecated 26 | ClientResponse fileUploadRequest(String historyId, 27 | String fileType, 28 | String dbKey, 29 | File file); 30 | 31 | ClientResponse uploadRequest(FileUploadRequest request); 32 | 33 | ToolExecution upload(FileUploadRequest request); 34 | 35 | /** 36 | * Show details about the specified tool. 37 | * 38 | * @param toolId the tool to look up. 39 | * @return details about the tool. 40 | */ 41 | Tool showTool(final String toolId); 42 | 43 | /** 44 | * Get a list of all tools installed in Galaxy. 45 | * 46 | * @return the list of tools installed in Galaxy. 47 | */ 48 | List getTools(); 49 | 50 | public static class UploadFile { 51 | private final File file; 52 | private final String name; 53 | 54 | public UploadFile(final File file) { 55 | this(file, file.getName()); 56 | } 57 | 58 | public UploadFile(final File file, final String name) { 59 | this.file = file; 60 | this.name =name; 61 | } 62 | 63 | public File getFile() { 64 | return file; 65 | } 66 | 67 | public String getName() { 68 | return name; 69 | } 70 | 71 | } 72 | 73 | public static class FileUploadRequest { 74 | private final String historyId; 75 | private final Iterable files; 76 | private String fileType = "auto"; 77 | private String dbKey = "?"; 78 | private String toolId = "upload1"; 79 | // Specify datasetName instead of file name, useful for multiple file uploads. 80 | private String datasetName = null; 81 | private Map extraParameters = new HashMap(); 82 | 83 | public Map getExtraParameters() { 84 | return extraParameters; 85 | } 86 | 87 | public void setExtraParameters(final Map extraParameters) { 88 | this.extraParameters = extraParameters; 89 | } 90 | 91 | private static Iterable convertFiles(final Iterable files) { 92 | final List uploadFiles = new ArrayList(); 93 | for(final File file : files) { 94 | uploadFiles.add(new UploadFile(file)); 95 | } 96 | return uploadFiles; 97 | } 98 | 99 | public FileUploadRequest(final String historyId, final File file) { 100 | this(historyId, convertFiles(Arrays.asList(file))); 101 | } 102 | 103 | public FileUploadRequest(final String historyId, final UploadFile file) { 104 | this(historyId, Arrays.asList(file)); 105 | } 106 | 107 | public FileUploadRequest(final String historyId, final Iterable files) { 108 | this.historyId = historyId; 109 | this.files = files; 110 | } 111 | 112 | public String getFileType() { 113 | return fileType; 114 | } 115 | 116 | public void setFileType(String fileType) { 117 | this.fileType = fileType; 118 | } 119 | 120 | public String getDbKey() { 121 | return dbKey; 122 | } 123 | 124 | public String getDatasetName() { 125 | return datasetName; 126 | } 127 | 128 | public void setDatasetName(String datasetName) { 129 | this.datasetName = datasetName; 130 | } 131 | 132 | public void setDbKey(String dbKey) { 133 | this.dbKey = dbKey; 134 | } 135 | 136 | public String getToolId() { 137 | return toolId; 138 | } 139 | 140 | public String getHistoryId() { 141 | return historyId; 142 | } 143 | 144 | public Iterable getFiles() { 145 | return files; 146 | } 147 | 148 | public Iterable getFileObjects() { 149 | final List files = new ArrayList(); 150 | for(final UploadFile uploadFile : getFiles()) { 151 | files.add(uploadFile.getFile()); 152 | } 153 | return files; 154 | 155 | } 156 | 157 | public void setToolId(String toolId) { 158 | this.toolId = toolId; 159 | } 160 | 161 | } 162 | 163 | } 164 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/ToolsClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.io.File; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.codehaus.jackson.type.TypeReference; 9 | 10 | import com.github.jmchilton.blend4j.galaxy.beans.History; 11 | import com.github.jmchilton.blend4j.galaxy.beans.Tool; 12 | import com.github.jmchilton.blend4j.galaxy.beans.ToolExecution; 13 | import com.github.jmchilton.blend4j.galaxy.beans.ToolInputs; 14 | import com.github.jmchilton.blend4j.galaxy.beans.ToolSection; 15 | import com.sun.jersey.api.client.ClientResponse; 16 | 17 | class ToolsClientImpl extends Client implements ToolsClient { 18 | ToolsClientImpl(GalaxyInstanceImpl galaxyInstance) { 19 | super(galaxyInstance, "tools"); 20 | } 21 | 22 | public ToolExecution create(History history, ToolInputs inputs) { 23 | inputs.setHistoryId(history.getId()); 24 | return super.create(inputs).getEntity(ToolExecution.class); 25 | // XXX Datasets not yet properly returned from Tool creation 26 | // return new ArrayList(); 27 | } 28 | 29 | public ClientResponse fileUploadRequest(final String historyId, 30 | final String fileType, 31 | final String dbKey, 32 | final File file) { 33 | final FileUploadRequest request = new FileUploadRequest(historyId, file); 34 | request.setFileType(fileType); 35 | request.setDbKey(dbKey); 36 | return uploadRequest(request); 37 | } 38 | 39 | public ToolExecution upload(final FileUploadRequest request) { 40 | return uploadRequest(request).getEntity(ToolExecution.class); 41 | } 42 | 43 | public ClientResponse uploadRequest(final FileUploadRequest request) { 44 | final Map uploadParameters = new HashMap(); 45 | final String datasetName = request.getDatasetName(); 46 | if(datasetName != null) { 47 | uploadParameters.put("files_0|NAME", datasetName); 48 | } else { 49 | uploadParameters.put("files_0|NAME", request.getFiles().iterator().next().getName()); 50 | } 51 | uploadParameters.put("dbkey", request.getDbKey()); 52 | uploadParameters.put("file_type", request.getFileType()); 53 | uploadParameters.putAll(request.getExtraParameters()); 54 | final Map requestParameters = new HashMap(); 55 | requestParameters.put("tool_id", request.getToolId()); 56 | requestParameters.put("history_id", request.getHistoryId()); 57 | requestParameters.put("inputs", write(uploadParameters)); 58 | requestParameters.put("type", "upload_dataset"); 59 | return multipartPost(getWebResource(), requestParameters, prepareUploads(request.getFileObjects())); 60 | } 61 | 62 | /** 63 | * {@inheritDoc} 64 | */ 65 | public Tool showTool(final String toolId) { 66 | return super.getWebResource(toolId).get(Tool.class); 67 | } 68 | 69 | 70 | public List getTools() { 71 | return get(new TypeReference>() {}); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/UsersClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.List; 4 | 5 | import com.github.jmchilton.blend4j.galaxy.beans.User; 6 | import com.github.jmchilton.blend4j.galaxy.beans.UserCreate; 7 | import com.sun.jersey.api.client.ClientResponse; 8 | 9 | public interface UsersClient { 10 | List getUsers(); 11 | 12 | ClientResponse createUserRequest(final String remoteUserEmail); 13 | 14 | User createUser(final String remoteUserEmail); 15 | 16 | ClientResponse createUserRequest(final UserCreate userCreate); 17 | 18 | User createUser(final UserCreate userCreate); 19 | 20 | String createApiKey(final String userId); 21 | 22 | User showUser(String id); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/UsersClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.codehaus.jackson.type.TypeReference; 9 | 10 | import com.github.jmchilton.blend4j.galaxy.beans.User; 11 | import com.github.jmchilton.blend4j.galaxy.beans.UserCreate; 12 | import com.sun.jersey.api.client.ClientResponse; 13 | 14 | class UsersClientImpl extends Client implements UsersClient { 15 | private static final TypeReference> USER_LIST_TYPE_REFERENCE = new TypeReference>() { 16 | }; 17 | 18 | UsersClientImpl(GalaxyInstanceImpl galaxyInstance) { 19 | super(galaxyInstance, "users"); 20 | } 21 | 22 | public List getUsers() { 23 | // Handles both User lists and single user retrieval 24 | try { 25 | return super.get(USER_LIST_TYPE_REFERENCE); 26 | } catch(RuntimeException e) { 27 | List out = new ArrayList(); 28 | out.add(super.getWebResource().get(User.class)); 29 | return out; 30 | } 31 | } 32 | 33 | public ClientResponse createUserRequest(final String remoteUserEmail) { 34 | final Map map = new HashMap(); 35 | map.put("remote_user_email", remoteUserEmail); 36 | return super.getWebResource().post(ClientResponse.class, write(map)); 37 | } 38 | 39 | public User createUser(final String remoteUserEmail) { 40 | return createUserRequest(remoteUserEmail).getEntity(User.class); 41 | } 42 | 43 | public User showUser(String id) { 44 | return super.show(id, User.class); 45 | } 46 | 47 | 48 | @Override 49 | public User createUser(UserCreate userCreate) { 50 | return createUserRequest(userCreate).getEntity(User.class); 51 | } 52 | 53 | @Override 54 | public String createApiKey(String userId) { 55 | return super.read(super.getWebResource().path(userId).path("api_key").post(ClientResponse.class), String.class); 56 | } 57 | 58 | @Override 59 | public ClientResponse createUserRequest(UserCreate userCreate) { 60 | return super.getWebResource().post(ClientResponse.class, write(userCreate)); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/WebResourceFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.sun.jersey.api.client.WebResource; 4 | 5 | public interface WebResourceFactory { 6 | /** 7 | * @return A Jersey WebResource setup to target http:///api and with the key query parameter set to 8 | * desired Galaxy key. 9 | */ 10 | public WebResource get(); 11 | 12 | @Deprecated 13 | public String getGalaxyUrl(); 14 | 15 | public String getUrl(); 16 | 17 | public String getApiKey(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/WorkflowsClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.List; 4 | 5 | import com.github.jmchilton.blend4j.galaxy.beans.Workflow; 6 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails; 7 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs; 8 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs; 9 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowInvocationInputs; 10 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowInvocationOutputs; 11 | import com.sun.jersey.api.client.ClientResponse; 12 | 13 | public interface WorkflowsClient { 14 | List getWorkflows(); 15 | 16 | WorkflowDetails showWorkflow(String workflowId); 17 | 18 | String exportWorkflow(String id); 19 | 20 | Workflow importWorkflow(String json); 21 | 22 | Workflow importWorkflow(String json, boolean publish); 23 | 24 | ClientResponse importWorkflowResponse(String json, final boolean publish); 25 | 26 | @Deprecated 27 | ClientResponse runWorkflowResponse(WorkflowInputs workflowInputs); 28 | 29 | @Deprecated 30 | WorkflowOutputs runWorkflow(WorkflowInputs workflowInputs); 31 | 32 | WorkflowInvocationOutputs invokeWorkflow(WorkflowInvocationInputs workflowInvocationInputs); 33 | 34 | /** 35 | * Deletes the workflow with the given id (this is irreversible). This will 36 | * return a {@link ClientResponse} object providing access to the status code 37 | * and the non-serialized body of the response. 38 | * 39 | * @param id 40 | * The id of the workflow to delete. 41 | * @return A {@link ClientResponse} for this request. The status code provided 42 | * by {@link ClientResponse#getClientResponseStatus()} should be 43 | * verified for success. 44 | */ 45 | ClientResponse deleteWorkflowRequest(String id); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/WorkflowsClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.List; 4 | 5 | import org.codehaus.jackson.type.TypeReference; 6 | 7 | import com.github.jmchilton.blend4j.galaxy.beans.Workflow; 8 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails; 9 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs; 10 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs; 11 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowInvocationInputs; 12 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowInvocationOutputs; 13 | import com.sun.jersey.api.client.ClientResponse; 14 | import com.sun.jersey.api.client.WebResource; 15 | 16 | class WorkflowsClientImpl extends Client implements WorkflowsClient { 17 | public WorkflowsClientImpl(GalaxyInstanceImpl galaxyInstance) { 18 | super(galaxyInstance, "workflows"); 19 | } 20 | 21 | public List getWorkflows() { 22 | return get(new TypeReference>() { 23 | }); 24 | } 25 | 26 | public ClientResponse showWorkflowResponse(final String id) { 27 | return super.show(id, ClientResponse.class); 28 | } 29 | 30 | public WorkflowDetails showWorkflow(final String id) { 31 | return super.show(id, WorkflowDetails.class); 32 | } 33 | 34 | public String exportWorkflow(final String id) { 35 | WebResource webResource = getWebResource().path("download").path(id); 36 | return webResource.get(String.class); 37 | } 38 | 39 | @Deprecated 40 | public ClientResponse runWorkflowResponse(WorkflowInputs workflowInputs) { 41 | return super.create(workflowInputs); 42 | } 43 | 44 | @Deprecated 45 | public WorkflowOutputs runWorkflow(final WorkflowInputs workflowInputs) { 46 | return runWorkflowResponse(workflowInputs).getEntity(WorkflowOutputs.class); 47 | } 48 | 49 | public ClientResponse runWorkflowInvocationResponse(WorkflowInvocationInputs workflowInvocationInputs) { 50 | return create(getWebResource().path(workflowInvocationInputs.getWorkflowId()).path("invocations"),workflowInvocationInputs); 51 | } 52 | 53 | public WorkflowInvocationOutputs invokeWorkflow(final WorkflowInvocationInputs workflowInvocationInputs) { 54 | return runWorkflowInvocationResponse(workflowInvocationInputs).getEntity(WorkflowInvocationOutputs.class); 55 | } 56 | 57 | public ClientResponse importWorkflowResponse(final String json, final boolean publish) { 58 | final String payload = String.format("{\"workflow\": %s, \"publish\": %s}", json, publish); 59 | return create(getWebResource().path("upload"), payload); 60 | } 61 | 62 | public Workflow importWorkflow(String json) { 63 | return importWorkflowResponse(json, false).getEntity(Workflow.class); 64 | } 65 | 66 | public Workflow importWorkflow(String json, boolean publish) { 67 | return importWorkflowResponse(json, publish).getEntity(Workflow.class); 68 | } 69 | 70 | @Override 71 | public ClientResponse deleteWorkflowRequest(String id) { 72 | return deleteResponse(getWebResource(id)); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/Dataset.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import com.github.jmchilton.blend4j.util.Objects; 4 | 5 | import org.codehaus.jackson.annotate.JsonIgnore; 6 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 7 | import org.codehaus.jackson.annotate.JsonProperty; 8 | 9 | import com.github.jmchilton.blend4j.galaxy.beans.collection.response.ElementResponse; 10 | 11 | @JsonIgnoreProperties(ignoreUnknown=true) 12 | public class Dataset extends HistoryContents implements HasGalaxyUrl, ElementResponse { 13 | private String dataType = null; 14 | private String fileExt = null; 15 | private String downloadUrl; 16 | private Integer fileSize; 17 | private String genomeBuild; 18 | private boolean visible; 19 | private String galaxyUrl; 20 | private String apiKey; 21 | private String info; 22 | private String blurb; 23 | 24 | public String getBlurb() { 25 | return blurb; 26 | } 27 | 28 | @JsonProperty("misc_blurb") 29 | public void setBlurb(String blurb) { 30 | this.blurb = blurb; 31 | } 32 | 33 | public String getInfo() { 34 | return info; 35 | } 36 | 37 | @JsonProperty("misc_info") 38 | public void setInfo(String info) { 39 | this.info = info; 40 | } 41 | 42 | 43 | public boolean getVisible() { 44 | return visible; 45 | } 46 | 47 | public void setVisible(boolean visible) { 48 | this.visible = visible; 49 | } 50 | 51 | /** 52 | * @deprecated As of 1.2 release, replaced by {@link #getDataTypeExt()}. 53 | */ 54 | @Deprecated 55 | public String getDataType() { 56 | return getDataTypeExt(); 57 | } 58 | 59 | public String getDataTypeExt() { 60 | // Hacked up due to backard incompatible changes made to the 61 | // Galaxy API as of the October 2014 release of Galaxy. 62 | // https://bitbucket.org/galaxy/galaxy-central/commits/9d152ed 63 | if(this.fileExt != null) { 64 | return this.fileExt; 65 | } else { 66 | return dataType; 67 | } 68 | } 69 | 70 | /** 71 | * This returns the Python module and class of the data type corresponding 72 | * to this object. (Starting from the October 2014 version of Galaxy.) 73 | * 74 | */ 75 | public String getDataTypeClass() { 76 | return dataType; 77 | } 78 | 79 | @JsonProperty("data_type") 80 | public void setDataType(String dataType) { 81 | // Meanaing of this property changed with October 2014 release (see note 82 | // above). 83 | this.dataType = dataType; 84 | } 85 | 86 | @JsonProperty("file_ext") 87 | public void setFileExt(final String fileExt) { 88 | this.fileExt = fileExt; 89 | } 90 | 91 | public String getDownloadUrl() { 92 | return downloadUrl; 93 | } 94 | 95 | @JsonProperty("download_url") 96 | public void setDownloadUrl(String downloadUrl) { 97 | this.downloadUrl = downloadUrl; 98 | } 99 | 100 | @JsonIgnore 101 | public String getFullDownloadUrl() { 102 | return String.format("%s%s?key=%s", 103 | getGalaxyUrl(), 104 | getDownloadUrl(), 105 | this.apiKey); 106 | } 107 | 108 | public String getGenomeBuild() { 109 | return genomeBuild; 110 | } 111 | 112 | @JsonProperty("genome_build") 113 | public void setGenomeBuild(String genomeBuild) { 114 | this.genomeBuild = genomeBuild; 115 | } 116 | 117 | public Integer getFileSize() { 118 | return fileSize; 119 | } 120 | 121 | @JsonProperty("file_size") 122 | public void setFileSize(Integer fileSize) { 123 | this.fileSize = fileSize; 124 | } 125 | 126 | @JsonIgnore 127 | public void setApiKey(final String apiKey) { 128 | this.apiKey = apiKey; 129 | } 130 | 131 | @JsonIgnore 132 | public void setGalaxyUrl(final String galaxyUrl) { 133 | this.galaxyUrl = galaxyUrl; 134 | } 135 | 136 | @JsonIgnore 137 | public String getGalaxyUrl() { 138 | return galaxyUrl; 139 | } 140 | 141 | @Override 142 | public int hashCode() { 143 | return Objects.hashCode(apiKey, blurb, dataType, downloadUrl, 144 | fileSize, galaxyUrl, genomeBuild, info, visible); 145 | } 146 | 147 | @Override 148 | public boolean equals(Object obj) { 149 | if (obj instanceof Dataset) { 150 | Dataset other = (Dataset)obj; 151 | 152 | return Objects.equal(apiKey, other.apiKey) && 153 | Objects.equal(blurb, other.blurb) && 154 | Objects.equal(dataType, other.dataType) && 155 | Objects.equal(downloadUrl, other.downloadUrl) && 156 | Objects.equal(fileSize, other.fileSize) && 157 | Objects.equal(galaxyUrl, other.galaxyUrl) && 158 | Objects.equal(genomeBuild, other.genomeBuild) && 159 | Objects.equal(info, other.info) && 160 | Objects.equal(visible, other.visible); 161 | } 162 | 163 | return false; 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/DirectoryLibraryUpload.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | 5 | public class DirectoryLibraryUpload extends LibraryUpload { 6 | public DirectoryLibraryUpload() { 7 | super("upload_directory"); 8 | } 9 | 10 | @JsonProperty("server_dir") 11 | public String getServerDirectory() { 12 | return getContent(); 13 | } 14 | 15 | @JsonProperty("files_0|url_paste") 16 | public String getDirectory() { 17 | return getContent(); 18 | } 19 | } -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/FileLibraryUpload.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.io.File; 4 | import org.codehaus.jackson.annotate.JsonIgnore; 5 | import org.codehaus.jackson.annotate.JsonProperty; 6 | 7 | public class FileLibraryUpload extends LibraryUpload { 8 | private File file; 9 | 10 | public FileLibraryUpload() { 11 | super("upload_file"); 12 | } 13 | 14 | public void setFile(final File file) { 15 | this.file = file; 16 | } 17 | 18 | @JsonIgnore 19 | public File getFile() { 20 | return file; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/FilesystemPathsLibraryUpload.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnore; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | public class FilesystemPathsLibraryUpload extends LibraryUpload { 7 | private boolean linkData; 8 | 9 | @JsonIgnore 10 | public boolean isLinkData() { 11 | return linkData; 12 | } 13 | 14 | public void setLinkData(final boolean linkData) { 15 | this.linkData = linkData; 16 | } 17 | 18 | public FilesystemPathsLibraryUpload() { 19 | this(false); 20 | } 21 | 22 | public FilesystemPathsLibraryUpload(final boolean multifile) { 23 | super(String.format("upload_paths%s", multifile ? "_multifile" : "")); 24 | } 25 | 26 | @JsonProperty("filesystem_paths") 27 | public String getFilesystemPaths() { 28 | return getContent(); 29 | } 30 | 31 | @JsonProperty("link_data_only") 32 | public String getLinkDataOnly() { 33 | return linkData ? "link_to_files" : "copy_files"; 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/GalaxyObject.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import com.github.jmchilton.blend4j.util.Objects; 4 | 5 | import org.codehaus.jackson.annotate.JsonIgnore; 6 | import org.codehaus.jackson.annotate.JsonProperty; 7 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 8 | 9 | @JsonIgnoreProperties(ignoreUnknown=true) 10 | public class GalaxyObject { 11 | private String id; 12 | private String url; 13 | 14 | @JsonProperty("id") 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | @JsonProperty("url") 20 | public void setUrl(String url) { 21 | this.url = url; 22 | } 23 | 24 | @JsonIgnore 25 | public String getUrl() { 26 | return url; 27 | } 28 | 29 | @JsonIgnore 30 | public String getId() { 31 | return id; 32 | } 33 | 34 | @Override 35 | public int hashCode() { 36 | return Objects.hashCode(id, url); 37 | } 38 | 39 | @Override 40 | public boolean equals(Object obj) { 41 | 42 | if (obj instanceof GalaxyObject) { 43 | GalaxyObject other = (GalaxyObject)obj; 44 | 45 | return Objects.equal(id, other.id) && 46 | Objects.equal(url, other.url); 47 | } 48 | 49 | return false; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/HasGalaxyUrl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | public interface HasGalaxyUrl { 4 | public void setGalaxyUrl(String galaxyUrl); 5 | 6 | public void setApiKey(final String apiKey); 7 | 8 | public String getGalaxyUrl(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/History.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 4 | 5 | @JsonIgnoreProperties(ignoreUnknown=true) 6 | public class History extends GalaxyObject { 7 | private String name; 8 | boolean deleted; 9 | 10 | public History() { 11 | } 12 | 13 | public History(final String name) { 14 | this.setName(name); 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public boolean isDeleted() { 26 | return deleted; 27 | } 28 | 29 | public void setDeleted(boolean deleted) { 30 | this.deleted = deleted; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/HistoryContents.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import com.github.jmchilton.blend4j.util.Objects; 4 | 5 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 6 | import org.codehaus.jackson.annotate.JsonProperty; 7 | 8 | @JsonIgnoreProperties(ignoreUnknown=true) 9 | public class HistoryContents extends GalaxyObject { 10 | private String name; 11 | private String type = "file"; 12 | private boolean deleted = false; 13 | private boolean purged = false; 14 | private int hid; 15 | private String historyContentType = "dataset"; 16 | private String state; 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(final String name) { 23 | this.name = name; 24 | } 25 | 26 | @Deprecated 27 | public String getType() { 28 | return type; 29 | } 30 | 31 | public void setType(final String type) { 32 | this.type = type; 33 | } 34 | 35 | public boolean isDeleted() { 36 | return deleted; 37 | } 38 | 39 | public void setDeleted(boolean deleted) { 40 | this.deleted = deleted; 41 | } 42 | 43 | public boolean isPurged() { 44 | return purged; 45 | } 46 | 47 | public void setPurged(boolean purged) { 48 | this.purged = purged; 49 | } 50 | 51 | public int getHid() { 52 | return hid; 53 | } 54 | 55 | public void setHid(int hid) { 56 | this.hid = hid; 57 | } 58 | 59 | public String getHistoryContentType() { 60 | return historyContentType; 61 | } 62 | 63 | @JsonProperty("history_content_type") 64 | public void setHistoryContentType(String historyContentType) { 65 | this.historyContentType = historyContentType; 66 | } 67 | 68 | public String getState() { 69 | return state; 70 | } 71 | 72 | public void setState(String state) { 73 | this.state = state; 74 | } 75 | 76 | @Override 77 | public int hashCode() { 78 | return Objects.hashCode(deleted, hid, historyContentType, name, purged, state, type); 79 | } 80 | 81 | @Override 82 | public boolean equals(Object obj) { 83 | if (obj instanceof HistoryContents) { 84 | HistoryContents other = (HistoryContents)obj; 85 | 86 | return Objects.equal(deleted, other.deleted) && 87 | Objects.equal(hid, other.hid) && 88 | Objects.equal(historyContentType, other.historyContentType) && 89 | Objects.equal(name, other.name) && 90 | Objects.equal(purged, other.purged) && 91 | Objects.equal(state, other.state) && 92 | Objects.equal(type, other.type); 93 | } 94 | 95 | return false; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/HistoryContentsProvenance.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.util.Map; 4 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 5 | import org.codehaus.jackson.annotate.JsonProperty; 6 | 7 | @JsonIgnoreProperties(ignoreUnknown=true) 8 | public class HistoryContentsProvenance { 9 | private String id; 10 | private String uuid; 11 | private String toolId; 12 | private String jobId; 13 | private String standardOutput; 14 | private String standardError; 15 | private Map parameters; 16 | 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | public void setId(String id) { 22 | this.id = id; 23 | } 24 | 25 | public String getUuid() { 26 | return uuid; 27 | } 28 | 29 | public void setUuid(String uuid) { 30 | this.uuid = uuid; 31 | } 32 | 33 | public String getToolId() { 34 | return toolId; 35 | } 36 | 37 | @JsonProperty("tool_id") 38 | public void setToolId(String toolId) { 39 | this.toolId = toolId; 40 | } 41 | 42 | public Map getParameters() { 43 | return parameters; 44 | } 45 | 46 | public void setParameters(Map parameters) { 47 | this.parameters = parameters; 48 | } 49 | 50 | public String getStandardOutput() { 51 | return standardOutput; 52 | } 53 | 54 | @JsonProperty("stdout") 55 | public void setStandardOutput(String standardOutput) { 56 | this.standardOutput = standardOutput; 57 | } 58 | 59 | public String getStandardError() { 60 | return standardError; 61 | } 62 | 63 | @JsonProperty("stderr") 64 | public void setStandardError(String standardError) { 65 | this.standardError = standardError; 66 | } 67 | 68 | public String getJobId() { 69 | return jobId; 70 | } 71 | 72 | @JsonProperty("job_id") 73 | public void setJobId(String jobId) { 74 | this.jobId = jobId; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/HistoryDataset.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | 4 | public class HistoryDataset { 5 | public static enum Source { 6 | LIBRARY("library"), HDA("hda"); 7 | 8 | private String source; 9 | 10 | private Source(final String source) { 11 | this.source = source; 12 | } 13 | 14 | public String toJson() { 15 | return source; 16 | } 17 | 18 | } 19 | 20 | private Source source; 21 | private String content; 22 | 23 | public String getContent() { 24 | return content; 25 | } 26 | 27 | public String getSource() { 28 | return source.toJson(); 29 | } 30 | 31 | public void setSource(final Source source) { 32 | this.source = source; 33 | } 34 | 35 | public void setContent(final String content) { 36 | this.content = content; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/HistoryDeleteResponse.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | /** 7 | * Defines the response from a delete request to Galaxy. 8 | */ 9 | @JsonIgnoreProperties(ignoreUnknown=true) 10 | public class HistoryDeleteResponse extends GalaxyObject { 11 | @JsonProperty("deleted") 12 | private boolean deleted; 13 | 14 | @JsonProperty("purged") 15 | private boolean purged; 16 | 17 | /** 18 | * Whether or not this object is deleted. 19 | * @return Whether or not this object is deleted. 20 | */ 21 | public boolean getDeleted() { 22 | return deleted; 23 | } 24 | 25 | /** 26 | * Whether or not this object is purged. 27 | * @return Whether or not this object is purged. 28 | */ 29 | public boolean getPurged() { 30 | return purged; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/HistoryDetails.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 7 | import org.codehaus.jackson.annotate.JsonProperty; 8 | 9 | @JsonIgnoreProperties(ignoreUnknown=true) 10 | public class HistoryDetails extends History { 11 | private String state; 12 | private Map> stateIds = new HashMap>(); 13 | 14 | public boolean isReady() { 15 | return !(state.equals("running") || state.equals("queued")); 16 | } 17 | 18 | public String getState() { 19 | return state; 20 | } 21 | 22 | public void setState(String state) { 23 | this.state = state; 24 | } 25 | 26 | @JsonProperty("state_ids") 27 | public void setStateIds(final Map> stateIds) { 28 | this.stateIds = stateIds; 29 | } 30 | 31 | public Map> getStateIds() { 32 | return stateIds; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/HistoryExport.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | @JsonIgnoreProperties(ignoreUnknown=true) 7 | public class HistoryExport { 8 | private String downloadUrl; 9 | 10 | public HistoryExport() { 11 | this.downloadUrl = null; 12 | } 13 | 14 | public HistoryExport(final String downloadUrl) { 15 | this.downloadUrl = downloadUrl; 16 | } 17 | 18 | public boolean isReady() { 19 | return this.downloadUrl != null; 20 | } 21 | 22 | public String getDownloadUrl() { 23 | return this.downloadUrl; 24 | } 25 | 26 | @JsonProperty("download_url") 27 | public void setDownloadUrl(final String downloadUrl) { 28 | this.downloadUrl = downloadUrl; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/InstallableRepositoryRevision.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import com.github.jmchilton.blend4j.toolshed.beans.RepositoryRevision; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | public class InstallableRepositoryRevision { 7 | @JsonProperty(value="changeset_revision") 8 | protected String changsetRevision; 9 | protected String name; 10 | protected String owner; 11 | @JsonProperty(value="tool_shed_url") 12 | protected String toolShedUrl = "https://toolshed.g2.bx.psu.edu/"; 13 | 14 | public InstallableRepositoryRevision() { 15 | } 16 | 17 | public InstallableRepositoryRevision(final String toolShedUrl, 18 | final RepositoryRevision repositoryRevision) { 19 | this.toolShedUrl = toolShedUrl; 20 | this.name = repositoryRevision.getName(); 21 | this.owner = repositoryRevision.getOwner(); 22 | this.changsetRevision = repositoryRevision.getRevision(); 23 | } 24 | 25 | public InstallableRepositoryRevision(final InstallableRepositoryRevision revision) { 26 | this.toolShedUrl = revision.getToolShedUrl(); 27 | this.changsetRevision = revision.getChangsetRevision(); 28 | this.owner = revision.getOwner(); 29 | this.name = revision.getName(); 30 | } 31 | 32 | public String getChangsetRevision() { 33 | return changsetRevision; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public String getOwner() { 41 | return owner; 42 | } 43 | 44 | public String getToolShedUrl() { 45 | return toolShedUrl; 46 | } 47 | 48 | public void setChangsetRevision(String changsetRevision) { 49 | this.changsetRevision = changsetRevision; 50 | } 51 | 52 | public void setName(String name) { 53 | this.name = name; 54 | } 55 | 56 | public void setOwner(String owner) { 57 | this.owner = owner; 58 | } 59 | 60 | public void setToolShedUrl(String toolShedUrl) { 61 | this.toolShedUrl = toolShedUrl; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/InstalledRepository.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | 5 | 6 | public class InstalledRepository extends GalaxyObject { 7 | @JsonProperty("changeset_revision") 8 | private String changesetRevision; 9 | @JsonProperty("ctx_rev") 10 | private int contextRevision; 11 | private boolean deleted; 12 | @JsonProperty("dist_to_shed") 13 | private boolean distToShed; 14 | @JsonProperty("error_message") 15 | private String errorMessage; 16 | @JsonProperty("includes_datatypes") 17 | private boolean includedDatatypes; 18 | @JsonProperty("installed_changeset_revision") 19 | private String installedChangesetRevision; 20 | private String name; 21 | private String owner; 22 | private String status; 23 | @JsonProperty("tool_shed") 24 | private String toolShed; 25 | private boolean uninstalled; 26 | @JsonProperty("update_avaiable") 27 | private boolean updateAvailable; 28 | 29 | public static enum InstallationStatus { 30 | NEW("New", false), 31 | CLONING("Cloning", false), 32 | SETTING_TOOL_VERSIONS("Setting tool versions", false), 33 | INSTALLING_REPOSITORY_DEPENDENCIES("Installing repository dependencies", false), 34 | INSTALLING_TOOL_DEPENDENCIES("Installing tool dependencies", false), 35 | LOADING_PROPRIETARY_DATATYPES("Loading proprietary datatypes", false), 36 | INSTALLED("Installed"), 37 | DEACTIVATED("Deactivated"), 38 | ERROR("Error"), 39 | UNINSTALLED("Uninstalled"); 40 | 41 | private final String text; 42 | private final boolean complete; 43 | 44 | private InstallationStatus(final String text) { 45 | this(text, true); 46 | } 47 | 48 | private InstallationStatus(final String text, final boolean complete) { 49 | this.text = text; 50 | this.complete = complete; 51 | } 52 | 53 | public boolean isComplete() { 54 | return complete; 55 | } 56 | 57 | public static InstallationStatus fromText(final String text) { 58 | InstallationStatus targetStatus = null; 59 | for(InstallationStatus status : values()) { 60 | if(status.text.equals(text)) { 61 | targetStatus = status; 62 | break; 63 | } 64 | } 65 | return targetStatus; 66 | } 67 | 68 | } 69 | 70 | public String getChangesetRevision() { 71 | return changesetRevision; 72 | } 73 | 74 | public void setChangesetRevision(String changesetRevision) { 75 | this.changesetRevision = changesetRevision; 76 | } 77 | 78 | public int getContextRevision() { 79 | return contextRevision; 80 | } 81 | 82 | public void setContextRevision(int contextRevision) { 83 | this.contextRevision = contextRevision; 84 | } 85 | 86 | public boolean isDeleted() { 87 | return deleted; 88 | } 89 | 90 | public void setDeleted(boolean deleted) { 91 | this.deleted = deleted; 92 | } 93 | 94 | public boolean isDistToShed() { 95 | return distToShed; 96 | } 97 | 98 | public void setDistToShed(boolean distToShed) { 99 | this.distToShed = distToShed; 100 | } 101 | 102 | public String getErrorMessage() { 103 | return errorMessage; 104 | } 105 | 106 | public void setErrorMessage(String errorMessage) { 107 | this.errorMessage = errorMessage; 108 | } 109 | 110 | public boolean isIncludedDatatypes() { 111 | return includedDatatypes; 112 | } 113 | 114 | public void setIncludedDatatypes(boolean includedDatatypes) { 115 | this.includedDatatypes = includedDatatypes; 116 | } 117 | 118 | public String getInstalledChangesetRevision() { 119 | return installedChangesetRevision; 120 | } 121 | 122 | public void setInstalledChangesetRevision(String installedChangesetRevision) { 123 | this.installedChangesetRevision = installedChangesetRevision; 124 | } 125 | 126 | public String getName() { 127 | return name; 128 | } 129 | 130 | public void setName(String name) { 131 | this.name = name; 132 | } 133 | 134 | public String getOwner() { 135 | return owner; 136 | } 137 | 138 | public void setOwner(String owner) { 139 | this.owner = owner; 140 | } 141 | 142 | public InstallationStatus getInstallationStatus() { 143 | return InstallationStatus.fromText(status); 144 | } 145 | 146 | public String getStatus() { 147 | return status; 148 | } 149 | 150 | public void setStatus(String status) { 151 | this.status = status; 152 | } 153 | 154 | public String getToolShed() { 155 | return toolShed; 156 | } 157 | 158 | public void setToolShed(String toolShed) { 159 | this.toolShed = toolShed; 160 | } 161 | 162 | public boolean isUninstalled() { 163 | return uninstalled; 164 | } 165 | 166 | public void setUninstalled(boolean uninstalled) { 167 | this.uninstalled = uninstalled; 168 | } 169 | 170 | public boolean isUpdateAvailable() { 171 | return updateAvailable; 172 | } 173 | 174 | public void setUpdateAvailable(boolean updateAvailable) { 175 | this.updateAvailable = updateAvailable; 176 | } 177 | 178 | } 179 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/Job.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.util.Date; 4 | 5 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 6 | import org.codehaus.jackson.annotate.JsonProperty; 7 | 8 | @JsonIgnoreProperties(ignoreUnknown = true) 9 | public class Job extends GalaxyObject { 10 | @JsonProperty("state") 11 | private String state; 12 | @JsonProperty("tool_id") 13 | private String toolId; 14 | @JsonProperty("create_time") 15 | private Date created; 16 | @JsonProperty("update_time") 17 | private Date updated; 18 | 19 | public final String getState() { 20 | return state; 21 | } 22 | public final void setState(String state) { 23 | this.state = state; 24 | } 25 | public final String getToolId() { 26 | return toolId; 27 | } 28 | public final void setToolId(String toolId) { 29 | this.toolId = toolId; 30 | } 31 | public final Date getCreated() { 32 | return created; 33 | } 34 | public final void setCreated(Date created) { 35 | this.created = created; 36 | } 37 | public final Date getUpdated() { 38 | return updated; 39 | } 40 | public final void setUpdated(Date updated) { 41 | this.updated = updated; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/JobDetails.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | 10 | @JsonIgnoreProperties(ignoreUnknown=true) 11 | public class JobDetails extends Job { 12 | @JsonProperty("command_line") 13 | private String commandLine; 14 | 15 | @JsonProperty("exit_code") 16 | private Integer exitCode; 17 | 18 | private Map inputs; 19 | 20 | private Map outputs; 21 | 22 | public Integer getExitCode() { 23 | return exitCode; 24 | } 25 | 26 | public void setExitCode(final Integer exitCode) { 27 | this.exitCode = exitCode; 28 | } 29 | 30 | public String getCommandLine() { 31 | return this.commandLine; 32 | } 33 | 34 | public void setCommandLine(final String commandLine) { 35 | this.commandLine = commandLine; 36 | } 37 | 38 | public Map getInputs() { 39 | return inputs; 40 | } 41 | 42 | public void setInputs(Map inputs) { 43 | this.inputs = inputs; 44 | } 45 | 46 | public Map getOutputs() { 47 | return outputs; 48 | } 49 | 50 | public void setOutputs(Map outputs) { 51 | this.outputs = outputs; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/JobInputOutput.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | public class JobInputOutput extends GalaxyObject { 7 | public static enum Source { 8 | library(), hda(), ldda(); 9 | 10 | private Source() { 11 | 12 | } 13 | 14 | public String toJson() { 15 | return name(); 16 | } 17 | 18 | } 19 | 20 | @JsonProperty("src") 21 | private Source source; 22 | 23 | public String getSource() { 24 | return source.name(); 25 | } 26 | 27 | public void setSource(final Source source) { 28 | this.source = source; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/Library.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | public class Library extends GalaxyObject { 4 | private String name = ""; 5 | private String description = ""; 6 | private String synopsis = ""; 7 | 8 | public Library() { 9 | } 10 | 11 | public Library(final String name) { 12 | this.name = name; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public String getDescription() { 24 | return description; 25 | } 26 | 27 | public void setDescription(String description) { 28 | this.description = description; 29 | } 30 | 31 | public String getSynopsis() { 32 | return synopsis; 33 | } 34 | 35 | public void setSynopsis(String synopsis) { 36 | this.synopsis = synopsis; 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/LibraryContent.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | public class LibraryContent extends GalaxyObject { 4 | private String name; 5 | private String type; 6 | 7 | public String getName() { 8 | return name; 9 | } 10 | 11 | public void setName(String name) { 12 | this.name = name; 13 | } 14 | 15 | public String getType() { 16 | return type; 17 | } 18 | 19 | public void setType(String type) { 20 | this.type = type; 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/LibraryFolder.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | 5 | public class LibraryFolder extends GalaxyObject { 6 | private String folderId; 7 | private String name; 8 | private String description = ""; 9 | 10 | @JsonProperty("folder_id") 11 | public String getFolderId() { 12 | return folderId; 13 | } 14 | 15 | @JsonProperty("folder_id") 16 | public void setFolderId(String folderId) { 17 | this.folderId = folderId; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | public String getDescription() { 29 | return description; 30 | } 31 | 32 | public void setDescription(String description) { 33 | this.description = description; 34 | } 35 | 36 | @JsonProperty("create_type") 37 | public String getCreateType() { 38 | return "folder"; 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/LibraryPermissions.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.codehaus.jackson.annotate.JsonProperty; 7 | 8 | public class LibraryPermissions { 9 | private List accessInRoles = new ArrayList(); 10 | private List modifyInRoles = new ArrayList(); 11 | private List addInRoles = new ArrayList(); 12 | private List manageInRoles = new ArrayList(); 13 | 14 | @JsonProperty("LIBRARY_ACCESS_in") 15 | public List getAccessInRoles() { 16 | return accessInRoles; 17 | } 18 | 19 | public void setAccessInRoles(List accessInRoles) { 20 | this.accessInRoles = accessInRoles; 21 | } 22 | 23 | @JsonProperty("LIBRARY_MODIFY_in") 24 | public List getModifyInRoles() { 25 | return modifyInRoles; 26 | } 27 | 28 | public void setModifyInRoles(List modifyInRoles) { 29 | this.modifyInRoles = modifyInRoles; 30 | } 31 | 32 | @JsonProperty("LIBRARY_ADD_in") 33 | public List getAddInRoles() { 34 | return addInRoles; 35 | } 36 | 37 | public void setAddInRoles(List addInRoles) { 38 | this.addInRoles = addInRoles; 39 | } 40 | 41 | @JsonProperty("LIBRARY_MANAGE_in") 42 | public List getManageInRoles() { 43 | return manageInRoles; 44 | } 45 | 46 | public void setManageInRoles(List manageInRoles) { 47 | this.manageInRoles = manageInRoles; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/LibraryUpload.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnore; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | import org.codehaus.jackson.map.annotate.JsonSerialize; 6 | 7 | public class LibraryUpload extends GalaxyObject { 8 | private String folderId; 9 | private String fileType = "auto"; 10 | private String dbkey = "?"; 11 | private String content; 12 | private String name; 13 | private final String uploadOption; 14 | private CreateType createType = CreateType.FILE; 15 | 16 | public static enum CreateType { 17 | FILE("file"); 18 | private String value; 19 | 20 | private CreateType(final String value) { 21 | this.value = value; 22 | } 23 | 24 | public String toJson() { 25 | return value; 26 | } 27 | } 28 | 29 | protected LibraryUpload(final String uploadOption) { 30 | this.uploadOption = uploadOption; 31 | } 32 | 33 | @JsonProperty("upload_option") 34 | public String getUploadOption() { 35 | return uploadOption; 36 | } 37 | 38 | @JsonIgnore 39 | public String getContent() { 40 | return content; 41 | } 42 | 43 | @JsonIgnore 44 | public void setContent(final String content) { 45 | this.content = content; 46 | } 47 | 48 | @JsonProperty("folder_id") 49 | public String getFolderId() { 50 | return folderId; 51 | } 52 | 53 | public void setFolderId(String folderId) { 54 | this.folderId = folderId; 55 | } 56 | 57 | @JsonProperty("file_type") 58 | public String getFileType() { 59 | return fileType; 60 | } 61 | 62 | public void setFileType(String fileType) { 63 | this.fileType = fileType; 64 | } 65 | 66 | public String getDbkey() { 67 | return dbkey; 68 | } 69 | 70 | public void setDbkey(String dbkey) { 71 | this.dbkey = dbkey; 72 | } 73 | 74 | public void setCreateType(final CreateType createType) { 75 | this.createType = createType; 76 | } 77 | 78 | @JsonProperty("create_type") 79 | public String getCreateType() { 80 | return createType.toJson(); 81 | } 82 | 83 | @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) 84 | @JsonProperty("NAME") 85 | public String getName() { 86 | return name; 87 | } 88 | 89 | public void setName(final String name) { 90 | this.name = name; 91 | } 92 | } -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/OutputDataset.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | 5 | 6 | public class OutputDataset extends Dataset { 7 | private String outputName; 8 | 9 | public String getOutputName() { 10 | return outputName; 11 | } 12 | 13 | @JsonProperty("output_name") 14 | public void setOutputName(String outputName) { 15 | this.outputName = outputName; 16 | } 17 | 18 | 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/RepositoryInstall.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | 5 | public class RepositoryInstall extends InstallableRepositoryRevision { 6 | @JsonProperty("new_tool_panel_section_label") 7 | private String newToolPanelSectionLabel = ""; 8 | @JsonProperty("tool_panel_section_id") 9 | private String toolPanelSectionId = ""; 10 | @JsonProperty("install_repository_dependencies") 11 | private boolean installRepositoryDependencies = false; 12 | @JsonProperty("install_tool_dependencies") 13 | private boolean installToolDependencies = false; 14 | 15 | public RepositoryInstall() { 16 | super(); 17 | } 18 | 19 | public RepositoryInstall(final InstallableRepositoryRevision revision) { 20 | super(revision); 21 | } 22 | 23 | 24 | public String getNewToolPanelSectionLabel() { 25 | return newToolPanelSectionLabel; 26 | } 27 | 28 | public void setNewToolPanelSectionLabel(String newToolPanelSectionLabel) { 29 | this.newToolPanelSectionLabel = newToolPanelSectionLabel; 30 | } 31 | 32 | public String getToolPanelSectionId() { 33 | return toolPanelSectionId; 34 | } 35 | 36 | public void setToolPanelSectionId(String toolPanelSectionId) { 37 | this.toolPanelSectionId = toolPanelSectionId; 38 | } 39 | 40 | public boolean isInstallRepositoryDependencies() { 41 | return installRepositoryDependencies; 42 | } 43 | 44 | public void setInstallRepositoryDependencies(boolean installRepositoryDependencies) { 45 | this.installRepositoryDependencies = installRepositoryDependencies; 46 | } 47 | 48 | public boolean isInstallToolDependencies() { 49 | return installToolDependencies; 50 | } 51 | 52 | public void setInstallToolDependencies(boolean installToolDependencies) { 53 | this.installToolDependencies = installToolDependencies; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/RepositoryWorkflow.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | @JsonIgnoreProperties(ignoreUnknown=true) 7 | public class RepositoryWorkflow { 8 | private int index; 9 | private String name; 10 | private String annotation; 11 | @JsonProperty("format-version") 12 | private String formatVersion; 13 | 14 | public int getIndex() { 15 | return index; 16 | } 17 | 18 | public void setIndex(final int index) { 19 | this.index = index; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(final String name) { 27 | this.name = name; 28 | } 29 | 30 | public String getAnnotation() { 31 | return annotation; 32 | } 33 | 34 | public void setAnnotation(final String annotation) { 35 | this.annotation = annotation; 36 | } 37 | 38 | public String getFormatVersion() { 39 | return formatVersion; 40 | } 41 | 42 | public void setFormatVersion(final String formatVersion) { 43 | this.formatVersion = formatVersion; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/Role.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | public class Role extends GalaxyObject { 4 | private String name; 5 | 6 | public String getName() { 7 | return name; 8 | } 9 | 10 | public void setName(String name) { 11 | this.name = name; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/TabularToolDataTable.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | @JsonIgnoreProperties(ignoreUnknown = true) 12 | public class TabularToolDataTable extends GalaxyObject { 13 | private String name; 14 | 15 | private List columns; 16 | 17 | private List> fields; 18 | 19 | @JsonProperty("name") 20 | protected void setName(final String name) { 21 | this.name = name; 22 | } 23 | 24 | public String getName() { 25 | return this.name; 26 | } 27 | 28 | @JsonProperty("columns") 29 | protected void setColumns(final List columns) { 30 | this.columns = columns; 31 | } 32 | 33 | public List getColumns() { 34 | return this.columns; 35 | } 36 | 37 | @JsonProperty("fields") 38 | protected void setFields(final List> fields) { 39 | this.fields = fields; 40 | } 41 | 42 | public List> getFields() { 43 | return this.fields; 44 | } 45 | 46 | public List getValues() { 47 | List columns = getColumns(); 48 | int valueIndex = columns.indexOf("value"); 49 | List> rows = getFields(); 50 | List values = new ArrayList(); 51 | for (List row : rows) { 52 | values.add(row.get(valueIndex)); 53 | } 54 | return values; 55 | } 56 | 57 | public List getFieldsListForValue(String value) { 58 | List columns = getColumns(); 59 | int valueIndex = columns.indexOf("value"); 60 | List> rows = getFields(); 61 | List fields = new ArrayList(); 62 | for (List row : rows) { 63 | if (row.get(valueIndex).equals(value)) { 64 | fields = row; 65 | } 66 | } 67 | return fields; 68 | } 69 | 70 | public Map getFieldsMapForValue(String value) { 71 | List columns = getColumns(); 72 | int valueIndex = columns.indexOf("value"); 73 | List> rows = getFields(); 74 | Map fields = new HashMap(); 75 | for (List row : rows) { 76 | if (row.get(valueIndex).equals(value)) { 77 | for (int i = 0; i < columns.size(); i++) { 78 | fields.put(columns.get(i), row.get(i)); 79 | } 80 | } 81 | } 82 | return fields; 83 | } 84 | 85 | public List getFieldsForColumn(String column) { 86 | List columns = getColumns(); 87 | int columnIndex = columns.indexOf(column); 88 | List> rows = getFields(); 89 | List fields = new ArrayList(); 90 | for (List row : rows) { 91 | fields.add(row.get(columnIndex)); 92 | } 93 | return fields; 94 | } 95 | 96 | public String getField(String value, String column) { 97 | String field = getFieldsMapForValue(value).get(column); 98 | return field; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/Tool.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | @JsonIgnoreProperties(ignoreUnknown = true) 7 | public class Tool extends GalaxyObject { 8 | private String version; 9 | 10 | private String description; 11 | 12 | private String name; 13 | 14 | private String link; 15 | 16 | private String target; 17 | 18 | @JsonProperty("link") 19 | protected void setLink(final String link) { 20 | this.link = link; 21 | } 22 | 23 | public String getLink() { 24 | return this.link; 25 | } 26 | 27 | @JsonProperty("target") 28 | protected void setTarget(final String target) { 29 | this.target = target; 30 | } 31 | 32 | public String getTarget() { 33 | return this.target; 34 | } 35 | 36 | @JsonProperty("description") 37 | protected void setDescription(final String description) { 38 | this.description = description; 39 | } 40 | 41 | public String getDescription() { 42 | return this.description; 43 | } 44 | 45 | @JsonProperty("version") 46 | protected void setVersion(final String version) { 47 | this.version = version; 48 | } 49 | 50 | public String getVersion() { 51 | return this.version; 52 | } 53 | 54 | @JsonProperty("name") 55 | protected void setName(final String name) { 56 | this.name = name; 57 | } 58 | 59 | public String getName() { 60 | return this.name; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/ToolExecution.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 6 | 7 | @JsonIgnoreProperties(ignoreUnknown=true) 8 | public class ToolExecution { 9 | private List outputs = new ArrayList(); 10 | 11 | public List getOutputs() { 12 | return outputs; 13 | } 14 | 15 | public void setOutputs(List outputs) { 16 | this.outputs = outputs; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/ToolInputs.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.util.Map; 4 | 5 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 6 | import org.codehaus.jackson.annotate.JsonProperty; 7 | 8 | public class ToolInputs { 9 | private String toolId; 10 | private String historyId; 11 | private Map inputs; 12 | 13 | public ToolInputs(String toolId, Map inputs) { 14 | this.toolId = toolId; 15 | this.inputs = inputs; 16 | } 17 | 18 | public void setHistoryId(String historyId) { 19 | this.historyId = historyId; 20 | } 21 | 22 | @JsonProperty("tool_id") 23 | public String getToolId() { 24 | return toolId; 25 | } 26 | 27 | @JsonProperty("inputs") 28 | public Map getInputs() { 29 | return inputs; 30 | } 31 | 32 | @JsonProperty("history_id") 33 | public String getHistoryId() { 34 | return historyId; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/ToolParameter.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | 5 | /** 6 | * 7 | * @author Mark Logghe 8 | * 9 | */ 10 | public class ToolParameter { 11 | private String parameterName; 12 | private String parameterValue; 13 | 14 | public ToolParameter(String parameterName, String parameterValue) { 15 | this.parameterName = parameterName; 16 | this.parameterValue = parameterValue; 17 | } 18 | 19 | @JsonProperty("param") 20 | public String getParameterName() { 21 | return parameterName; 22 | } 23 | 24 | public void setParameterName(String parameterName) { 25 | this.parameterName = parameterName; 26 | } 27 | 28 | @JsonProperty("value") 29 | public String getParameterValue() { 30 | return parameterValue; 31 | } 32 | 33 | public void setParameterValue(String parameterValue) { 34 | this.parameterValue = parameterValue; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/ToolSection.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.util.List; 4 | 5 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 6 | import org.codehaus.jackson.annotate.JsonProperty; 7 | 8 | import com.github.jmchilton.blend4j.galaxy.ToolsClient; 9 | 10 | /** 11 | * Very basic details about tools. For more information about a tool, load a 12 | * {@link ToolDetails} instance with {@link ToolsClient#showTool}. 13 | * 14 | * @author Franklin Bristow franklin.bristow@phac-aspc.gc.ca 15 | * 16 | */ 17 | @JsonIgnoreProperties(ignoreUnknown = true) 18 | public class ToolSection extends GalaxyObject { 19 | private String version; 20 | 21 | private String name; 22 | 23 | private String description; 24 | 25 | private List elems; 26 | 27 | @JsonProperty("description") 28 | protected void setDescription(final String description) { 29 | this.description = description; 30 | } 31 | 32 | public String getDescription() { 33 | return this.description; 34 | } 35 | 36 | @JsonProperty("elems") 37 | protected void setElems(final List elems) { 38 | this.elems = elems; 39 | } 40 | 41 | public List getElems() { 42 | return this.elems; 43 | } 44 | 45 | 46 | @JsonProperty("version") 47 | protected void setVersion(final String version) { 48 | this.version = version; 49 | } 50 | 51 | public String getVersion() { 52 | return this.version; 53 | } 54 | 55 | @JsonProperty("name") 56 | protected void setName(final String name) { 57 | this.name = name; 58 | } 59 | 60 | public String getName() { 61 | return this.name; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/UrlLibraryUpload.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | 5 | public class UrlLibraryUpload extends LibraryUpload { 6 | protected UrlLibraryUpload() { 7 | super("upload_file"); 8 | } 9 | 10 | @JsonProperty("files_0|url_paste") 11 | public String getUrl() { 12 | return getContent(); 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/User.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | @JsonIgnoreProperties(ignoreUnknown=true) 7 | public class User extends GalaxyObject { 8 | private String email; 9 | private String username; 10 | 11 | public String getEmail() { 12 | return email; 13 | } 14 | 15 | public void setEmail(final String email) { 16 | this.email = email; 17 | } 18 | 19 | @JsonProperty("nice_total_disk_usage") 20 | public void setNiceTotalDiskUsage(final String niceTotalDiskUsage) { 21 | } 22 | 23 | @JsonProperty("total_disk_usage") 24 | public void setTotalDiskUsage(final String totalDiskUsage) { 25 | } 26 | 27 | public void setUsername(final String username) { 28 | this.username = username; 29 | } 30 | 31 | public String getUsername() { 32 | return username; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/UserCreate.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | 5 | public class UserCreate { 6 | private String username; 7 | private String email; 8 | private String password; 9 | 10 | @JsonProperty 11 | public String getUsername() { 12 | return username; 13 | } 14 | 15 | public void setUsername(final String username) { 16 | this.username = username; 17 | } 18 | 19 | @JsonProperty 20 | public String getEmail() { 21 | return email; 22 | } 23 | 24 | public void setEmail(final String email) { 25 | this.email = email; 26 | } 27 | 28 | @JsonProperty 29 | public String getPassword() { 30 | return password; 31 | } 32 | 33 | public void setPassword(final String password) { 34 | this.password = password; 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/Workflow.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | public class Workflow extends GalaxyObject { 4 | private String name; 5 | 6 | public String getName() { 7 | return name; 8 | } 9 | 10 | public void setName(String name) { 11 | this.name = name; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/WorkflowDetails.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.util.Map; 4 | 5 | public class WorkflowDetails extends Workflow { 6 | private boolean deleted; 7 | private boolean published; 8 | private String owner; 9 | private Map inputs; 10 | private Map steps; 11 | 12 | public boolean isDeleted() { 13 | return deleted; 14 | } 15 | 16 | public void setDeleted(boolean deleted) { 17 | this.deleted = deleted; 18 | } 19 | 20 | public boolean isPublished() { 21 | return published; 22 | } 23 | 24 | public void setPublished(boolean published) { 25 | this.published = published; 26 | } 27 | 28 | public String getOwner() { 29 | return owner; 30 | } 31 | 32 | public void setOwner(String owner) { 33 | this.owner = owner; 34 | } 35 | 36 | public Map getSteps() { 37 | return steps; 38 | } 39 | 40 | public void setSteps(Map steps) { 41 | this.steps = steps; 42 | } 43 | 44 | public void setInputs(final Map inputs) { 45 | this.inputs = inputs; 46 | } 47 | 48 | public Map getInputs() { 49 | return inputs; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/WorkflowInputDefinition.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | @JsonIgnoreProperties(ignoreUnknown=true) 7 | public class WorkflowInputDefinition { 8 | private String value; 9 | private String label; 10 | @JsonProperty("uuid") 11 | private String uuid; 12 | 13 | public void setValue(final String value) { 14 | this.value = value; 15 | } 16 | 17 | public String getValue() { 18 | return value; 19 | } 20 | 21 | public void setLabel(final String label) { 22 | this.label = label; 23 | } 24 | 25 | public String getLabel() { 26 | return label; 27 | } 28 | 29 | public void setUuid(final String uuid) { 30 | this.uuid = uuid; 31 | } 32 | 33 | public String getUuid() { 34 | return uuid; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/WorkflowInputs.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnore; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | import org.codehaus.jackson.annotate.JsonValue; 6 | import org.codehaus.jackson.map.annotate.JsonSerialize; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | public class WorkflowInputs { 12 | // Why are we posting to /workflows and putting this in the payload instead 13 | // of posting to /workflows/. Seems incongruous/unrestful. 14 | private String workflowId; 15 | private WorkflowDestination destination; 16 | private boolean importInputsToHistory = false; 17 | private Map inputs = new HashMap(); 18 | private Map> parameters = new HashMap>(); 19 | 20 | public void setWorkflowId(final String workflowId) { 21 | this.workflowId = workflowId; 22 | } 23 | 24 | @JsonProperty("workflow_id") 25 | public String getWorkflowId() { 26 | return workflowId; 27 | } 28 | 29 | public void setDestination(final WorkflowDestination destination) { 30 | this.destination = destination; 31 | } 32 | 33 | @JsonProperty("history") 34 | public WorkflowDestination getDestination() { 35 | return destination; 36 | } 37 | 38 | public void setInput(final String inputName, final WorkflowInput workflowInput) { 39 | this.inputs.put(inputName, workflowInput); 40 | } 41 | 42 | @JsonProperty("ds_map") 43 | public Map getInputs() { 44 | return inputs; 45 | } 46 | 47 | @Deprecated 48 | public void setParameter(final String toolId, final ToolParameter toolParameter) { 49 | this.setToolParameter(toolId, toolParameter); 50 | } 51 | 52 | public void setToolParameter(final String toolId, final String parameterName, final Object parameterValue) { 53 | this.setParameter(toolId, parameterName, parameterValue); 54 | } 55 | 56 | public void setToolParameter(final String toolId, final ToolParameter toolParameter) { 57 | this.setParameter(toolId, toolParameter.getParameterName(), toolParameter.getParameterValue()); 58 | } 59 | 60 | // Some parts of API return step ids as strings others as ints - allow either 61 | public void setStepParameter(final String stepId, final String parameterName, final Object parameterValue) { 62 | this.setParameter(stepId, parameterName, parameterValue); 63 | } 64 | 65 | public void setStepParameter(final int stepId, final String parameterName, final Object parameterValue) { 66 | this.setParameter(stepId, parameterName, parameterValue); 67 | } 68 | 69 | public void setStepParameter(final String stepId, final ToolParameter toolParameter) { 70 | this.setParameter(stepId, toolParameter.getParameterName(), toolParameter.getParameterValue()); 71 | } 72 | 73 | public void setStepParameter(final int stepId, final ToolParameter toolParameter) { 74 | this.setParameter(stepId, toolParameter.getParameterName(), toolParameter.getParameterValue()); 75 | } 76 | 77 | synchronized private void setParameter(final Object toolOrStepId, final String parameterName, final Object parameterValue) { 78 | Map keyValueMap = this.parameters.get(toolOrStepId); 79 | if(keyValueMap == null) { 80 | keyValueMap = new HashMap(); 81 | } 82 | keyValueMap.put(parameterName, parameterValue); 83 | this.parameters.put(toolOrStepId, keyValueMap); 84 | } 85 | 86 | @JsonProperty("parameters") 87 | @JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY) 88 | public Map> getParameters() { 89 | return parameters; 90 | } 91 | 92 | @JsonProperty("no_add_to_history") 93 | @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) 94 | public String getNoAddToHistory() { 95 | return importInputsToHistory ? null : "true"; 96 | } 97 | 98 | @JsonIgnore 99 | public boolean getImportInputsToHistory() { 100 | return importInputsToHistory; 101 | } 102 | 103 | public void setImportInputsToHistory(final boolean importInputsToHistory) { 104 | this.importInputsToHistory = importInputsToHistory; 105 | } 106 | 107 | public static class WorkflowDestination { 108 | } 109 | 110 | public static class NewHistory extends WorkflowDestination { 111 | private String name; 112 | 113 | public NewHistory(final String name) { 114 | this.name = name; 115 | } 116 | 117 | @JsonValue 118 | public String value() { 119 | return name; 120 | } 121 | } 122 | 123 | public static class ExistingHistory extends WorkflowDestination { 124 | private String id; 125 | 126 | public ExistingHistory(final String id) { 127 | this.id = id; 128 | } 129 | 130 | @JsonValue 131 | public String value() { 132 | return String.format("hist_id=%s", id); 133 | } 134 | } 135 | 136 | public static class WorkflowInput { 137 | private String id; 138 | private InputSourceType inputSourceType; 139 | 140 | public WorkflowInput(final String id, final InputSourceType inputSourceType) { 141 | this.id = id; 142 | this.inputSourceType = inputSourceType; 143 | } 144 | 145 | public String getId() { 146 | return id; 147 | } 148 | 149 | @JsonProperty("src") 150 | public InputSourceType getSourceType() { 151 | return inputSourceType; 152 | } 153 | } 154 | 155 | /** 156 | * Defines the different Workflow Input source types. 157 | */ 158 | public enum InputSourceType { 159 | 160 | /** 161 | * Library dataset dataset association 162 | */ 163 | LDDA("ldda"), 164 | 165 | /** 166 | * Library dataset 167 | */ 168 | LD("ld"), 169 | 170 | /** 171 | * History dataset association 172 | */ 173 | HDA("hda"), 174 | 175 | /** 176 | * History dataset collection association 177 | */ 178 | HDCA("hdca"); 179 | 180 | private final String rawValue; 181 | 182 | private InputSourceType(final String rawValue) { 183 | this.rawValue = rawValue; 184 | } 185 | 186 | @JsonValue 187 | public String value() { 188 | return rawValue; 189 | } 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/WorkflowInvocationOutputs.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | 10 | @JsonIgnoreProperties(ignoreUnknown=true) 11 | public class WorkflowInvocationOutputs { 12 | private String historyId; 13 | private String id; 14 | private Map inputs = new HashMap(); 15 | private String modelClass; 16 | private String state; 17 | private Map steps; 18 | private String updateTime; 19 | private String uuid; 20 | private String workflowId; 21 | 22 | 23 | public String getHistoryId() { 24 | return historyId; 25 | } 26 | 27 | @JsonProperty("history_id") 28 | public void setHistoryId(final String historyId) { 29 | this.historyId = historyId; 30 | } 31 | 32 | public String getId() {return id;} 33 | 34 | @JsonProperty("id") 35 | public void setId(String id) {this.id = id;} 36 | 37 | public void setInput(final String inputName, final WorkflowInvocationInputs.WorkflowInvocationInput workflowInvocationInput) { 38 | this.inputs.put(inputName, workflowInvocationInput); 39 | } 40 | 41 | @JsonProperty("inputs") 42 | public Map getInputs() { 43 | return inputs; 44 | } 45 | 46 | public String getModelClass() { 47 | return modelClass; 48 | } 49 | 50 | @JsonProperty("model_class") 51 | public void setModelClass(final String modelClass) { 52 | this.modelClass = modelClass; 53 | } 54 | 55 | public String getState() { 56 | return state; 57 | } 58 | 59 | @JsonProperty("state") 60 | public void setState(final String state) { 61 | this.state = state; 62 | } 63 | 64 | @JsonProperty("steps") 65 | public Map getSteps() { 66 | return steps; 67 | } 68 | 69 | public void setSteps(Map steps) { 70 | this.steps = steps; 71 | } 72 | 73 | public String getUpdateTime() {return updateTime;} 74 | 75 | @JsonProperty("update_time") 76 | public void setUpdateTime(String updateTime) {this.updateTime = updateTime;} 77 | 78 | public String getUuid() {return uuid;} 79 | 80 | @JsonProperty("uuid") 81 | public void setUuid(String uuid) {this.uuid = uuid;} 82 | 83 | public String getWorkflowId() {return workflowId;} 84 | 85 | @JsonProperty("workflow_id") 86 | public void setWorkflowId(String workflowId) {this.workflowId = workflowId;} 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/WorkflowOutputs.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.util.List; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 6 | 7 | 8 | @JsonIgnoreProperties(ignoreUnknown=true) 9 | public class WorkflowOutputs { 10 | private String historyId; 11 | private List outputIds; 12 | 13 | public List getOutputIds() { 14 | return outputIds; 15 | } 16 | 17 | @JsonProperty("outputs") 18 | public void setOutputIds(final List outputIds) { 19 | this.outputIds = outputIds; 20 | } 21 | 22 | public String getHistoryId() { 23 | return historyId; 24 | } 25 | 26 | @JsonProperty("history") 27 | public void setHistoryId(final String historyId) { 28 | this.historyId = historyId; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/WorkflowStepDefinition.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans; 2 | 3 | import java.util.Map; 4 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 5 | import org.codehaus.jackson.annotate.JsonProperty; 6 | 7 | 8 | @JsonIgnoreProperties(ignoreUnknown=true) 9 | public class WorkflowStepDefinition { 10 | 11 | @JsonIgnoreProperties(ignoreUnknown=true) 12 | public static class WorkflowStepOutput { 13 | private String stepOutput; 14 | private String sourceStep; 15 | 16 | public String getStepOutput() { 17 | return stepOutput; 18 | } 19 | 20 | @JsonProperty("step_output") 21 | public void setStepOutput(String stepOutput) { 22 | this.stepOutput = stepOutput; 23 | } 24 | 25 | public String getSourceStep() { 26 | return sourceStep; 27 | } 28 | 29 | @JsonProperty("source_step") 30 | public void setSourceStep(String sourceStep) { 31 | this.sourceStep = sourceStep; 32 | } 33 | 34 | } 35 | 36 | private Map inputSteps; 37 | private String type; // data_input or tool 38 | 39 | @JsonProperty("input_steps") 40 | public void setInputSteps(final Map inputSteps) { 41 | this.inputSteps = inputSteps; 42 | } 43 | 44 | public Map getInputSteps() { 45 | return this.inputSteps; 46 | } 47 | 48 | public String getType() { 49 | return type; 50 | } 51 | 52 | public void setType(String type) { 53 | this.type = type; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/collection/CollectionSource.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans.collection; 2 | 3 | import org.codehaus.jackson.annotate.JsonValue; 4 | 5 | /** 6 | * Describes the source of data for a dataset collection. 7 | */ 8 | public enum CollectionSource { 9 | 10 | /** 11 | * The dataset source is from a History. 12 | */ 13 | HDA("hda"), 14 | 15 | /** 16 | * The dataset source is a new collection. 17 | */ 18 | COLLECTION("new_collection"); 19 | 20 | private String source; 21 | 22 | private CollectionSource(final String source) { 23 | this.source = source; 24 | } 25 | 26 | @JsonValue 27 | public String getSource() { 28 | return source; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/collection/request/AbstractElement.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans.collection.request; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | 5 | import com.github.jmchilton.blend4j.galaxy.beans.collection.CollectionSource; 6 | 7 | /** 8 | * Description for elements used to create a dataset collection in Galaxy. 9 | */ 10 | public abstract class AbstractElement { 11 | 12 | @JsonProperty("name") 13 | private String name; 14 | 15 | @JsonProperty("src") 16 | private CollectionSource source; 17 | 18 | /** 19 | * Gets the source of this element. 20 | * @return The source of this element. 21 | */ 22 | public CollectionSource getSource() { 23 | return source; 24 | } 25 | 26 | /** 27 | * Sets the source of this element. 28 | * @param source The source of this element. 29 | */ 30 | public void setSource(CollectionSource source) { 31 | this.source = source; 32 | } 33 | 34 | /** 35 | * Gets the name of this element. 36 | * @return The name of this element. 37 | */ 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | /** 43 | * Sets the name of this element. 44 | * @param name The name of this element. 45 | */ 46 | public void setName(String name) { 47 | this.name = name; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/collection/request/CollectionDescription.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans.collection.request; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | import org.codehaus.jackson.annotate.JsonProperty; 7 | 8 | /** 9 | * A request to create a collection of elements (datasets or other collections) within Galaxy. 10 | */ 11 | public class CollectionDescription { 12 | 13 | @JsonProperty("name") 14 | private String name; 15 | 16 | @JsonProperty("type") 17 | private String type = "dataset_collection"; 18 | 19 | @JsonProperty("collection_type") 20 | private String collectionType = "list"; 21 | 22 | @JsonProperty("element_identifiers") 23 | private List datasetElements 24 | = new LinkedList(); 25 | 26 | /** 27 | * Gets the name of this dataset collection. 28 | * @return The name of this dataset collection. 29 | */ 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | /** 35 | * Sets the name of this dataset collection. 36 | * @param name The name of this dataset collection. 37 | */ 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | /** 43 | * Gets a list of elements within this dataset collection. 44 | * @return A list of elements within this dataset collection. 45 | */ 46 | public List getDatasetElements() { 47 | return datasetElements; 48 | } 49 | 50 | /** 51 | * Adds an element to this dataset collection. 52 | * @param datasetElement The dataset element to add. 53 | */ 54 | public void addDatasetElement(AbstractElement datasetElement) { 55 | this.datasetElements.add(datasetElement); 56 | } 57 | 58 | /** 59 | * Gets the collection type. 60 | * @return The collection type. 61 | */ 62 | public String getCollectionType() { 63 | return collectionType; 64 | } 65 | 66 | /** 67 | * Sets the collection type. 68 | * @param collectionType The collection type. 69 | */ 70 | public void setCollectionType(String collectionType) { 71 | this.collectionType = collectionType; 72 | } 73 | 74 | /** 75 | * Gets the type of this request. 76 | * @return The type of this request. 77 | */ 78 | public String getType() { 79 | return type; 80 | } 81 | 82 | /** 83 | * Sets the type of this request. 84 | * @param type The type of this request. 85 | */ 86 | public void setType(String type) { 87 | this.type = type; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/collection/request/CollectionElement.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans.collection.request; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | import org.codehaus.jackson.annotate.JsonProperty; 7 | 8 | import com.github.jmchilton.blend4j.galaxy.beans.collection.CollectionSource; 9 | 10 | /** 11 | * Class defining an element in a collection that can contain other collection elements. 12 | */ 13 | public class CollectionElement extends AbstractElement { 14 | 15 | @JsonProperty("element_identifiers") 16 | private List collectionElements 17 | = new LinkedList(); 18 | 19 | @JsonProperty("collection_type") 20 | private String collectionType = "list"; 21 | 22 | public CollectionElement() { 23 | setSource(CollectionSource.COLLECTION); 24 | } 25 | 26 | /** 27 | * Gets the list of contained collection elements. 28 | * @return The list of contained collection elements. 29 | */ 30 | public List getCollectionElements() { 31 | return collectionElements; 32 | } 33 | 34 | /** 35 | * Adds an element to this dataset collection. 36 | * @param collectionElement The dataset element to add. 37 | */ 38 | public void addCollectionElement(AbstractElement collectionElement) { 39 | this.collectionElements.add(collectionElement); 40 | } 41 | 42 | /** 43 | * Gets the type of this collection. 44 | * @return The type of this collection. 45 | */ 46 | public String getCollectionType() { 47 | return collectionType; 48 | } 49 | 50 | /** 51 | * Sets the type of this collection. 52 | * @param collectionType The type of this collection. 53 | */ 54 | public void setCollectionType(String collectionType) { 55 | this.collectionType = collectionType; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/collection/request/HistoryDatasetElement.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans.collection.request; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.beans.collection.CollectionSource; 4 | 5 | /** 6 | * Class describing a history dataset to be placed within a collection. 7 | */ 8 | public class HistoryDatasetElement extends SimpleElement { 9 | 10 | /** 11 | * Builds a new HistoryDatasetElement. 12 | */ 13 | public HistoryDatasetElement() { 14 | setSource(CollectionSource.HDA); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/collection/request/SimpleElement.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans.collection.request; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | 5 | /** 6 | * Class describing requests for the creation of a simple element in a dataset (no sub elements). 7 | */ 8 | public abstract class SimpleElement extends AbstractElement { 9 | 10 | @JsonProperty("id") 11 | private String id; 12 | 13 | /** 14 | * Gets the id of this element. 15 | * @return The id of this element. 16 | */ 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | /** 22 | * Sets the id of this element. 23 | * @param id The id of this element. 24 | */ 25 | public void setId(String id) { 26 | this.id = id; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/collection/response/CollectionElementResponse.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans.collection.response; 2 | 3 | import com.github.jmchilton.blend4j.util.Objects; 4 | 5 | import org.codehaus.jackson.annotate.JsonProperty; 6 | import org.codehaus.jackson.annotate.JsonSubTypes; 7 | import org.codehaus.jackson.annotate.JsonTypeInfo; 8 | 9 | import com.github.jmchilton.blend4j.galaxy.beans.Dataset; 10 | 11 | /** 12 | * 13 | * Represents a collection of elements from a dataset collection response from Galaxy. 14 | */ 15 | public class CollectionElementResponse { 16 | 17 | @JsonProperty("element_identifier") 18 | private String elementIdentifier; 19 | 20 | @JsonProperty("element_index") 21 | private int elementIndex; 22 | 23 | @JsonProperty("element_type") 24 | private String elementType; 25 | 26 | @JsonProperty("id") 27 | private String id; 28 | 29 | @JsonProperty("model_class") 30 | private String modelClass; 31 | 32 | @JsonProperty("collection_type") 33 | private String collectionType; 34 | 35 | @JsonProperty("object") 36 | @JsonTypeInfo( 37 | use = JsonTypeInfo.Id.NAME, 38 | include = JsonTypeInfo.As.EXTERNAL_PROPERTY, 39 | property="element_type") 40 | @JsonSubTypes({ 41 | @JsonSubTypes.Type(value = Dataset.class, name="hda"), 42 | @JsonSubTypes.Type(value = CollectionResponse.class, name="dataset_collection") 43 | }) 44 | private ElementResponse elementResponse; 45 | 46 | /** 47 | * Gets the identifier of the elements in this collection. 48 | * @return The identifier of the elements in this collection. 49 | */ 50 | public String getElementIdentifier() { 51 | return elementIdentifier; 52 | } 53 | 54 | /** 55 | * Sets the identifer of elements in this collection. 56 | * @param elementIdentifier An identifier of elements in this collection. 57 | */ 58 | public void setElementIdentifier(String elementIdentifier) { 59 | this.elementIdentifier = elementIdentifier; 60 | } 61 | 62 | /** 63 | * Gets the index of this particular element in a collection. 64 | * @return The index of this element in a collection. 65 | */ 66 | public int getElementIndex() { 67 | return elementIndex; 68 | } 69 | 70 | /** 71 | * Sets the index of this element in a collection. 72 | * @param elementIndex The index of this element in a collection. 73 | */ 74 | public void setElementIndex(int elementIndex) { 75 | this.elementIndex = elementIndex; 76 | } 77 | 78 | /** 79 | * Gets the type of elements in this collection. 80 | * @return The type of elements in this collection. 81 | */ 82 | public String getElementType() { 83 | return elementType; 84 | } 85 | 86 | /** 87 | * Sets the type of elements in this collection. 88 | * @param elementType The type of elements in this collection. 89 | */ 90 | public void setElementType(String elementType) { 91 | this.elementType = elementType; 92 | } 93 | 94 | /** 95 | * Gets the id of this collection element. 96 | * @return The id of this collection element. 97 | */ 98 | public String getId() { 99 | return id; 100 | } 101 | 102 | /** 103 | * Sets the id of this collection element. 104 | * @param id The id of this collection element. 105 | */ 106 | public void setId(String id) { 107 | this.id = id; 108 | } 109 | 110 | /** 111 | * Gets the class of this collection. 112 | * @return The class of this collection. 113 | */ 114 | public String getModelClass() { 115 | return modelClass; 116 | } 117 | 118 | /** 119 | * Sets the class of this collection. 120 | * @param modelClass The class of this collection. 121 | */ 122 | public void setModelClass(String modelClass) { 123 | this.modelClass = modelClass; 124 | } 125 | 126 | /** 127 | * Gets the response element within this collection. 128 | * @return The response element within this collection. 129 | */ 130 | public ElementResponse getResponseElement() { 131 | return elementResponse; 132 | } 133 | 134 | /** 135 | * Sets the data element within this collection. 136 | * @param response The data element within this collection. 137 | */ 138 | public void setResponseObject(ElementResponse response) { 139 | this.elementResponse = response; 140 | } 141 | 142 | /** 143 | * Gets the type of this collection. 144 | * @return The type of this collection. 145 | */ 146 | public String getCollectionType() { 147 | return collectionType; 148 | } 149 | 150 | /** 151 | * Sets the type of this collection. 152 | * @param collectionType The type of this collection. 153 | */ 154 | public void setCollectionType(String collectionType) { 155 | this.collectionType = collectionType; 156 | } 157 | 158 | @Override 159 | public int hashCode() { 160 | return Objects.hashCode(collectionType, elementIdentifier, elementIndex, elementType, id, modelClass, elementResponse); 161 | } 162 | 163 | @Override 164 | public boolean equals(Object obj) { 165 | if (obj instanceof CollectionElementResponse) { 166 | CollectionElementResponse other = (CollectionElementResponse)obj; 167 | 168 | return Objects.equal(collectionType, other.collectionType) && 169 | Objects.equal(elementIdentifier, other.elementIdentifier) && 170 | Objects.equal(elementIndex, other.elementIndex) && 171 | Objects.equal(elementType, other.elementType) && 172 | Objects.equal(id, other.id) && 173 | Objects.equal(modelClass, other.modelClass) && 174 | Objects.equal(elementResponse, other.elementResponse); 175 | } 176 | 177 | return false; 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/collection/response/CollectionResponse.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans.collection.response; 2 | 3 | import java.util.List; 4 | import com.github.jmchilton.blend4j.util.Objects; 5 | 6 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 7 | import org.codehaus.jackson.annotate.JsonProperty; 8 | 9 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryContents; 10 | 11 | /** 12 | * Class for storing response information from Galaxy on a dataset collection within a History. 13 | */ 14 | @JsonIgnoreProperties(ignoreUnknown=true) 15 | public class CollectionResponse extends HistoryContents implements ElementResponse { 16 | 17 | @JsonProperty("elements") 18 | private List elements; 19 | 20 | @JsonProperty("collection_type") 21 | private String collectionType; 22 | 23 | @JsonProperty("history_id") 24 | private String historyId; 25 | 26 | @JsonProperty("visible") 27 | private boolean visible; 28 | 29 | /** 30 | * Gets a list of elements within this collection. 31 | * @return A list of elements within this collection. 32 | */ 33 | public List getElements() { 34 | return elements; 35 | } 36 | 37 | /** 38 | * Sets the list of elements within this collection. 39 | * @param elements A list of elements within this collection. 40 | */ 41 | public void setElements(List elements) { 42 | this.elements = elements; 43 | } 44 | 45 | /** 46 | * Gets the type of this collection. 47 | * @return The type fo this collection. 48 | */ 49 | public String getCollectionType() { 50 | return collectionType; 51 | } 52 | 53 | /** 54 | * Sets the type of this collection. 55 | * @param collectionType The type of this collection. 56 | */ 57 | public void setCollectionType(String collectionType) { 58 | this.collectionType = collectionType; 59 | } 60 | 61 | /** 62 | * Gets the id of the history this collection exists within. 63 | * @return The id of the history this collection exists within. 64 | */ 65 | public String getHistoryId() { 66 | return historyId; 67 | } 68 | 69 | /** 70 | * Sets the id of the history this collection exists within. 71 | * @param historyId The id of the history this collection exists within. 72 | */ 73 | public void setHistoryId(String historyId) { 74 | this.historyId = historyId; 75 | } 76 | 77 | /** 78 | * Gets the visible status of this collection. 79 | * @return The visible status of this collection. 80 | */ 81 | public boolean isVisible() { 82 | return visible; 83 | } 84 | 85 | /** 86 | * Sets the visible status of this collection. 87 | * @param visible The visible status of this collection. 88 | */ 89 | public void setVisible(boolean visible) { 90 | this.visible = visible; 91 | } 92 | 93 | @Override 94 | public int hashCode() { 95 | return Objects.hashCode(collectionType, elements, historyId, visible); 96 | } 97 | 98 | @Override 99 | public boolean equals(Object obj) { 100 | if (obj instanceof CollectionResponse) { 101 | CollectionResponse other = (CollectionResponse)obj; 102 | 103 | return Objects.equal(collectionType, other.collectionType) && 104 | Objects.equal(elements, other.elements) && 105 | Objects.equal(historyId, other.historyId) && 106 | Objects.equal(visible, other.visible); 107 | } 108 | 109 | return false; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/galaxy/beans/collection/response/ElementResponse.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy.beans.collection.response; 2 | 3 | /** 4 | * Interface defining an element within a dataset collection. 5 | */ 6 | public interface ElementResponse { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/Client.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed; 2 | 3 | import com.github.jmchilton.blend4j.BaseClient; 4 | import com.github.jmchilton.blend4j.galaxy.WebResourceFactory; 5 | 6 | class Client extends BaseClient { 7 | 8 | Client(final WebResourceFactory webResourceFactory, final String module) { 9 | super(webResourceFactory.get(), module); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/RepositoriesClient.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed; 2 | 3 | import com.github.jmchilton.blend4j.toolshed.beans.Repository; 4 | import com.github.jmchilton.blend4j.toolshed.beans.RepositoryDetails; 5 | import com.github.jmchilton.blend4j.toolshed.beans.RepositoryRevision; 6 | import com.sun.jersey.api.client.ClientResponse; 7 | import java.util.List; 8 | 9 | public interface RepositoriesClient { 10 | 11 | List getRepositories(); 12 | 13 | RepositoryDetails showRepository(final String repositoryId); 14 | 15 | ClientResponse getInstallableRevisionsRequest(final Repository repository); 16 | 17 | List getInstallableRevisions(final Repository repository); 18 | 19 | // API returns a list (length 3) of heterogenous data structures. Maybe should wait until a cleaned up 20 | // version of this is available. 21 | ClientResponse getRepositoryRevisionInstallInfoRequest(final RepositoryRevision revision); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/RepositoriesClientImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.WebResourceFactory; 4 | import com.github.jmchilton.blend4j.toolshed.beans.Repository; 5 | import com.github.jmchilton.blend4j.toolshed.beans.RepositoryDetails; 6 | import com.github.jmchilton.blend4j.toolshed.beans.RepositoryRevision; 7 | import com.sun.jersey.api.client.ClientResponse; 8 | import com.sun.jersey.api.client.WebResource; 9 | import java.util.List; 10 | import org.codehaus.jackson.type.TypeReference; 11 | 12 | public class RepositoriesClientImpl extends Client implements RepositoriesClient { 13 | private static final TypeReference> TOOL_LIST_TYPE_REFERENCE = new TypeReference>() { 14 | }; 15 | private static final TypeReference> STRING_LIST_TYPE_REFERENCE = new TypeReference>() { 16 | }; 17 | 18 | RepositoriesClientImpl(WebResourceFactory webResourceFactory) { 19 | super(webResourceFactory, "repositories"); 20 | } 21 | 22 | public List getRepositories() { 23 | return super.get(TOOL_LIST_TYPE_REFERENCE); 24 | } 25 | 26 | public RepositoryDetails showRepository(final String repositoryId) { 27 | return super.show(repositoryId, RepositoryDetails.class); 28 | } 29 | 30 | public ClientResponse getInstallableRevisionsRequest(Repository repository) { 31 | return super.getResponse(withQueryParams(super.path("get_ordered_installable_revisions"), repository)); 32 | } 33 | 34 | public List getInstallableRevisions(Repository repository) { 35 | return read(getInstallableRevisionsRequest(repository), STRING_LIST_TYPE_REFERENCE); 36 | } 37 | 38 | public ClientResponse getRepositoryRevisionInstallInfoRequest(RepositoryRevision revision) { 39 | final WebResource baseResource = super.path("get_repository_revision_install_info"); 40 | final WebResource resource = withQueryParams(baseResource, revision); 41 | return super.getResponse(resource); 42 | } 43 | 44 | private WebResource withQueryParams(final WebResource resource, RepositoryRevision revision) { 45 | return withQueryParams(resource, (Repository) revision).queryParam("changeset_revision", revision.getRevision()); 46 | } 47 | 48 | private WebResource withQueryParams(final WebResource resource, final Repository repository) { 49 | return resource.queryParam("owner", repository.getOwner()).queryParam("name", repository.getName()); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/RepositoryUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed; 2 | 3 | import com.github.jmchilton.blend4j.toolshed.beans.Repository; 4 | import com.github.jmchilton.blend4j.toolshed.beans.RepositoryRevision; 5 | import java.util.List; 6 | 7 | public class RepositoryUtils { 8 | 9 | public static RepositoryRevision getLatestRepositoryRevision(final RepositoriesClient client, final String owner, final String name) { 10 | return getLatestRepositoryRevision(client, new Repository(owner, name)); 11 | } 12 | 13 | public static RepositoryRevision getLatestRepositoryRevision(final RepositoriesClient client, final Repository repository) { 14 | final List installableRevisions = client.getInstallableRevisions(repository); 15 | final String latest = installableRevisions.get(installableRevisions.size() - 1); 16 | return new RepositoryRevision(repository, latest); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/ToolShedInstance.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed; 2 | 3 | public interface ToolShedInstance { 4 | 5 | RepositoriesClient getRepositoriesClient(); 6 | 7 | public String getUrl(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/ToolShedInstanceFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.DefaultWebResourceFactoryImpl; 4 | import com.github.jmchilton.blend4j.galaxy.WebResourceFactory; 5 | 6 | public class ToolShedInstanceFactory { 7 | 8 | public static ToolShedInstance get(final String url, final String apiKey) { 9 | return get(new DefaultWebResourceFactoryImpl(url, apiKey)); 10 | } 11 | 12 | public static ToolShedInstance get(final WebResourceFactory webResourceFactory) { 13 | return new ToolShedInstanceImpl(webResourceFactory); 14 | } 15 | 16 | public static ToolShedInstance getMainToolShedInstance() { 17 | return getMainToolShedInstance(null); 18 | } 19 | 20 | public static ToolShedInstance getMainToolShedInstance(final String apiKey) { 21 | return get("https://toolshed.g2.bx.psu.edu/", apiKey); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/ToolShedInstanceImpl.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.WebResourceFactory; 4 | 5 | class ToolShedInstanceImpl implements ToolShedInstance { 6 | private WebResourceFactory webResourceFactory; 7 | 8 | ToolShedInstanceImpl(final WebResourceFactory webResourceFactory) { 9 | this.webResourceFactory = webResourceFactory; 10 | } 11 | 12 | public RepositoriesClient getRepositoriesClient() { 13 | return new RepositoriesClientImpl(webResourceFactory); 14 | } 15 | 16 | public String getUrl() { 17 | return webResourceFactory.getUrl(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/ToolShedUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.beans.InstallableRepositoryRevision; 4 | import com.github.jmchilton.blend4j.toolshed.beans.Repository; 5 | import com.github.jmchilton.blend4j.toolshed.beans.RepositoryRevision; 6 | 7 | public class ToolShedUtils { 8 | 9 | public static InstallableRepositoryRevision getLatestInstallableRevision(final Repository repository) { 10 | return getLatestInstallableRevision(ToolShedInstanceFactory.getMainToolShedInstance(), repository); 11 | } 12 | 13 | public static InstallableRepositoryRevision getLatestInstallableRevision(final ToolShedInstance instance, final Repository repository) { 14 | final RepositoryRevision revision; 15 | revision = RepositoryUtils.getLatestRepositoryRevision(instance.getRepositoriesClient(), repository); 16 | final InstallableRepositoryRevision installableRevision; 17 | installableRevision = new InstallableRepositoryRevision(instance.getUrl(), revision); 18 | return installableRevision; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/beans/Repository.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed.beans; 2 | 3 | public class Repository { 4 | private String owner; 5 | private String name; 6 | 7 | public Repository() { 8 | } 9 | 10 | public Repository(String owner, String name) { 11 | this.owner = owner; 12 | this.name = name; 13 | } 14 | 15 | public String getOwner() { 16 | return owner; 17 | } 18 | 19 | public void setOwner(String owner) { 20 | this.owner = owner; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | @Override 32 | public int hashCode() { 33 | int hash = 5; 34 | hash = 71 * hash + (this.owner != null ? this.owner.hashCode() : 0); 35 | hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0); 36 | return hash; 37 | } 38 | 39 | @Override 40 | public boolean equals(Object obj) { 41 | if(obj == null) { 42 | return false; 43 | } 44 | if(getClass() != obj.getClass()) { 45 | return false; 46 | } 47 | final Repository other = (Repository) obj; 48 | if((this.owner == null) ? (other.owner != null) : !this.owner.equals(other.owner)) { 49 | return false; 50 | } 51 | if((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { 52 | return false; 53 | } 54 | return true; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "Repository{" + "owner=" + owner + ", name=" + name + '}'; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/beans/RepositoryDetails.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed.beans; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.beans.GalaxyObject; 4 | import org.codehaus.jackson.annotate.JsonProperty; 5 | 6 | public class RepositoryDetails extends GalaxyObject { 7 | @JsonProperty("times_downloaded") 8 | private int timesDownloaded; 9 | @JsonProperty("user_id") 10 | private String userId; 11 | private String description; 12 | private boolean deleted; 13 | private boolean deprecated; 14 | @JsonProperty("private") 15 | private boolean private_; 16 | private String owner; 17 | private String type; 18 | private String name; 19 | 20 | public int getTimesDownloaded() { 21 | return timesDownloaded; 22 | } 23 | 24 | public void setTimesDownloaded(int timesDownloaded) { 25 | this.timesDownloaded = timesDownloaded; 26 | } 27 | 28 | public String getUserId() { 29 | return userId; 30 | } 31 | 32 | public void setUserId(String userId) { 33 | this.userId = userId; 34 | } 35 | 36 | public String getDescription() { 37 | return description; 38 | } 39 | 40 | public void setDescription(String description) { 41 | this.description = description; 42 | } 43 | 44 | public boolean isDeleted() { 45 | return deleted; 46 | } 47 | 48 | public void setDeleted(boolean deleted) { 49 | this.deleted = deleted; 50 | } 51 | 52 | public boolean isDeprecated() { 53 | return deprecated; 54 | } 55 | 56 | public void setDeprecated(boolean deprecated) { 57 | this.deprecated = deprecated; 58 | } 59 | 60 | public boolean isPrivate_() { 61 | return private_; 62 | } 63 | 64 | public void setPrivate_(boolean private_) { 65 | this.private_ = private_; 66 | } 67 | 68 | public String getOwner() { 69 | return owner; 70 | } 71 | 72 | public void setOwner(String owner) { 73 | this.owner = owner; 74 | } 75 | 76 | public String getType() { 77 | return type; 78 | } 79 | 80 | public void setType(String type) { 81 | this.type = type; 82 | } 83 | 84 | public String getName() { 85 | return name; 86 | } 87 | 88 | public void setName(String name) { 89 | this.name = name; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/toolshed/beans/RepositoryRevision.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed.beans; 2 | 3 | // TODO: Swap this to use delegation instead of inheritence. 4 | public class RepositoryRevision extends Repository { 5 | private String revision; 6 | 7 | public RepositoryRevision() { 8 | } 9 | 10 | public RepositoryRevision(final Repository repository, final String revision) { 11 | this(repository.getOwner(), repository.getName(), revision); 12 | } 13 | 14 | public RepositoryRevision(final String owner, final String name, final String revision) { 15 | super(owner, name); 16 | this.revision = revision; 17 | } 18 | 19 | public String getRevision() { 20 | return revision; 21 | } 22 | 23 | public void setRevision(final String revision) { 24 | this.revision = revision; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/jmchilton/blend4j/util/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Subset of Google Guava (version 17) copied into library (and modified slightly) 3 | * so the functionality is available but we don't actually need to depend on another 4 | * library. 5 | * 6 | */ 7 | package com.github.jmchilton.blend4j.util; 8 | -------------------------------------------------------------------------------- /src/test/java/com/github/jmchilton/blend4j/galaxy/ConfigurationTest.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.util.Map; 4 | import org.testng.annotations.Test; 5 | 6 | public class ConfigurationTest { 7 | 8 | @Test 9 | public void testPathPaste() { 10 | final GalaxyInstance galaxyInstance = TestGalaxyInstance.get(); 11 | final ConfigurationClient client = galaxyInstance.getConfigurationClient(); 12 | final Map config = client.getRawConfiguration(); 13 | assert config.containsKey("terms_url"); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/github/jmchilton/blend4j/galaxy/JobsTest.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.io.IOException; 4 | import java.net.URISyntaxException; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | 8 | import org.testng.annotations.BeforeMethod; 9 | import org.testng.annotations.Test; 10 | 11 | import com.github.jmchilton.blend4j.galaxy.beans.History; 12 | import com.github.jmchilton.blend4j.galaxy.beans.Job; 13 | import com.github.jmchilton.blend4j.galaxy.beans.JobDetails; 14 | import com.github.jmchilton.blend4j.galaxy.beans.JobInputOutput; 15 | import com.sun.jersey.api.client.ClientResponse; 16 | 17 | /** 18 | * Tests for Galaxy's Jobs API. 19 | * 20 | * @author Franklin Bristow franklin.bristow@phac-aspc.gc.ca 21 | * 22 | */ 23 | public class JobsTest { 24 | private GalaxyInstance instance; 25 | private JobsClient client; 26 | private HistoriesClient hClient; 27 | 28 | @BeforeMethod 29 | public void init() throws URISyntaxException, IOException, InterruptedException { 30 | instance = TestGalaxyInstance.get(); 31 | client = instance.getJobsClient(); 32 | hClient = instance.getHistoriesClient(); 33 | 34 | // Create test dataset/upload job 35 | String historyId = TestHelpers.getTestHistoryId(instance); 36 | TestHelpers.populateTestDataset(this.instance, historyId, "Test Contents"); 37 | } 38 | 39 | @Test 40 | public void testGetJobs() { 41 | final List jobs = client.getJobs(); 42 | assert jobs != null; 43 | assert !jobs.isEmpty(); 44 | 45 | for (final Job job : jobs) { 46 | assert job.getId() != null; 47 | } 48 | } 49 | 50 | @Test 51 | public void testGetJobDetails() { 52 | final List jobs = client.getJobs(); 53 | assert jobs != null; 54 | assert !jobs.isEmpty(); 55 | 56 | final Job job = jobs.iterator().next(); 57 | final JobDetails deets = client.showJob(job.getId()); 58 | 59 | assert deets != null; 60 | assert deets.getCommandLine() != null; 61 | assert deets.getExitCode() != null; 62 | } 63 | 64 | @Test 65 | public void testGetJobDetailsFromUploadedFileInLibrary() { 66 | // Upload file to library to test out a library upload job 67 | ClientResponse response = TestHelpers.testUploadToLibrary(instance); 68 | assert 200 == response.getStatus() : "Uploading to library did not give correct response"; 69 | 70 | final List jobs = client.getJobs(); 71 | assert jobs != null; 72 | assert !jobs.isEmpty(); 73 | 74 | final Job job = jobs.iterator().next(); 75 | final JobDetails deets = client.showJob(job.getId()); 76 | 77 | assert deets != null; 78 | assert JobInputOutput.Source.ldda.name().equals(deets.getOutputs().get("output0").getSource()); 79 | } 80 | 81 | /** 82 | * check that the jobs filtered by history id are a subset of the full set 83 | * of jobs. 84 | */ 85 | @Test 86 | public void testGetJobsForHistory() { 87 | final List allJobs = client.getJobs(); 88 | 89 | assert allJobs != null; 90 | assert !allJobs.isEmpty(); 91 | 92 | final List histories = hClient.getHistories(); 93 | assert histories != null; 94 | assert !histories.isEmpty(); 95 | 96 | final Iterator historyIterator = histories.iterator(); 97 | History history; 98 | List historyJobs; 99 | do { 100 | history = historyIterator.next(); 101 | historyJobs = client.getJobsForHistory(history.getId()); 102 | } while(historyJobs.size() == 0 && historyIterator.hasNext()); 103 | 104 | assert historyJobs != null; 105 | assert !historyJobs.isEmpty(); 106 | 107 | assert allJobs.size() >= historyJobs.size(); 108 | assert allJobs.containsAll(historyJobs); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/test/java/com/github/jmchilton/blend4j/galaxy/ObjectMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.io.IOException; 4 | 5 | import org.codehaus.jackson.JsonGenerationException; 6 | import org.codehaus.jackson.map.JsonMappingException; 7 | import org.codehaus.jackson.map.ObjectMapper; 8 | import org.testng.annotations.Test; 9 | 10 | import com.github.jmchilton.blend4j.galaxy.beans.LibraryPermissions; 11 | import com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs; 12 | 13 | // Not a true unit test, just a place to play around with Jackson mapping. 14 | public class ObjectMapperTest { 15 | @Test 16 | public void testSerialization() throws JsonGenerationException, JsonMappingException, IOException { 17 | final ObjectMapper mapper = new ObjectMapper(); 18 | LibraryPermissions libraryPermissions = new LibraryPermissions(); 19 | libraryPermissions.getAccessInRoles().add("moocow"); 20 | mapper.writer().writeValueAsString(libraryPermissions); 21 | 22 | final WorkflowInputs inputs = new WorkflowInputs(); 23 | inputs.setToolParameter("randomlines", "num_lines", 5); 24 | mapper.writer().writeValueAsString(libraryPermissions); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/com/github/jmchilton/blend4j/galaxy/SearchTest.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.SearchClient.SearchResponse; 4 | import com.github.jmchilton.blend4j.galaxy.beans.FileLibraryUpload; 5 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset; 6 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset.Source; 7 | import com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails; 8 | import com.github.jmchilton.blend4j.galaxy.beans.Library; 9 | import com.github.jmchilton.blend4j.galaxy.beans.LibraryContent; 10 | import com.google.common.collect.Iterables; 11 | import com.sun.jersey.api.client.ClientResponse; 12 | import java.io.File; 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | import java.util.UUID; 16 | import org.testng.annotations.BeforeMethod; 17 | import org.testng.annotations.Test; 18 | 19 | public class SearchTest { 20 | private GalaxyInstance instance; 21 | private SearchClient client; 22 | 23 | @BeforeMethod 24 | public void init() { 25 | instance = TestGalaxyInstance.get(); 26 | client = instance.getSearchClient(); 27 | } 28 | 29 | /* // Time dependent test that fails intermittently. 30 | @Test 31 | public void testListJobs() throws InterruptedException { 32 | final String historyId = TestHelpers.getTestHistoryId(instance); 33 | final HistoriesClient historyClient = instance.getHistoriesClient(); 34 | SearchResponse response = client.search("select * from job where state = 'new'"); 35 | assert response.getResults().size() == 0; 36 | final File input1 = TestHelpers.getTestFile(); 37 | TestHelpers.testUpload(instance, historyId, input1); 38 | response = client.search("select * from job where state = 'new'"); 39 | assert response.getResults().size() == 1; 40 | final Map failedJob = response.getResults().get(0); 41 | TestHelpers.waitForHistory(instance.getHistoriesClient(), historyId); 42 | } 43 | */ 44 | 45 | @Test 46 | public void testLdda() throws InterruptedException { 47 | final File testFile = TestHelpers.getTestFile(); 48 | final LibrariesClient client = IntegrationTest.getLibrariesClient(); 49 | final Library testLibrary = IntegrationTest.createTestLibrary(client, "test-filesystem-paths" + UUID.randomUUID().toString()); 50 | final LibraryContent rootFolder = client.getRootFolder(testLibrary.getId()); 51 | final FileLibraryUpload upload = new FileLibraryUpload(); 52 | upload.setName("MOOCOWFILE"); 53 | upload.setFolderId(rootFolder.getId()); 54 | upload.setFileType("tabular"); 55 | upload.setFile(testFile); 56 | final ClientResponse uploadResponse = client.uploadFile(testLibrary.getId(), upload); 57 | IntegrationTest.assert200(uploadResponse); 58 | 59 | final String historyId = TestHelpers.getTestHistoryId(instance); 60 | final HistoryDataset hd = new HistoryDataset(); 61 | hd.setSource(Source.LIBRARY); 62 | final String lddaId = client.getLibraryContents(testLibrary.getId()).get(1).getId(); 63 | hd.setContent(lddaId); 64 | final HistoryDetails hda = instance.getHistoriesClient().createHistoryDataset(historyId, hd); 65 | final String id = instance.getHistoriesClient().showHistoryContents(historyId).get(0).getId(); 66 | 67 | SearchResponse response; 68 | final String query = "select copied_from_ldda_id from hda where id = '" + id + "'"; 69 | response = instance.getSearchClient().search(query); 70 | assert response.getResults().get(0).get("copied_from_ldda_id").equals(lddaId); 71 | TestHelpers.waitForHistory(instance.getHistoriesClient(), historyId); 72 | 73 | } 74 | 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/test/java/com/github/jmchilton/blend4j/galaxy/TestGalaxyInstance.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.github.jmchilton.blend4j.Config; 4 | import com.github.jmchilton.galaxybootstrap.BootStrapper; 5 | import com.github.jmchilton.galaxybootstrap.BootStrapper.GalaxyDaemon; 6 | import com.github.jmchilton.galaxybootstrap.DownloadProperties; 7 | import com.github.jmchilton.galaxybootstrap.GalaxyData; 8 | import com.github.jmchilton.galaxybootstrap.GalaxyProperties; 9 | 10 | import java.io.File; 11 | import java.io.FileInputStream; 12 | import java.io.FileOutputStream; 13 | import java.io.IOException; 14 | import java.net.URISyntaxException; 15 | import java.nio.channels.FileChannel; 16 | import java.util.Properties; 17 | 18 | import org.testng.annotations.AfterSuite; 19 | import org.testng.annotations.BeforeSuite; 20 | 21 | public class TestGalaxyInstance { 22 | private static Properties properties = Config.loadBlendProperties(); 23 | private static GalaxyDaemon galaxyDaemon = null; 24 | private static String testApiKey = null; 25 | private static String testUrl = null; 26 | 27 | @BeforeSuite 28 | public static void bootStrapGalaxy() throws URISyntaxException, IOException { 29 | if(getTestApiKey() == null) { 30 | DownloadProperties downloadProperties = DownloadProperties.forRelease("release_17.01"); 31 | if(Boolean.getBoolean(System.getProperty("galaxy.bootstrap.github", "false"))){ 32 | downloadProperties = DownloadProperties.wgetGithubMaster(); 33 | } 34 | final BootStrapper bootStrapper = new BootStrapper(downloadProperties); 35 | bootStrapper.setupGalaxy(); 36 | final GalaxyProperties galaxyProperties = 37 | new GalaxyProperties() 38 | .assignFreePort() 39 | .prepopulateSqliteDatabase() 40 | .configureNestedShedTools(); 41 | final GalaxyData galaxyData = new GalaxyData(); 42 | final GalaxyData.User adminUser = new GalaxyData.User("admin@localhost"); 43 | final GalaxyData.User normalUser = new GalaxyData.User("user@localhost"); 44 | galaxyData.getUsers().add(adminUser); 45 | galaxyData.getUsers().add(normalUser); 46 | galaxyProperties.setAdminUser("admin@localhost"); 47 | galaxyProperties.setAppProperty("allow_library_path_paste", "true"); 48 | galaxyProperties.setAppProperty("library_import_dir", "."); 49 | galaxyProperties.setAppProperty("tool_dependency_dir", "tool_dependencies"); 50 | final int port = galaxyProperties.getPort(); 51 | 52 | buildTestTools(galaxyProperties, bootStrapper.getPath()); 53 | 54 | testApiKey = adminUser.getApiKey(); 55 | testUrl = String.format("http://localhost:%d/", port); 56 | 57 | galaxyDaemon = bootStrapper.run(galaxyProperties, galaxyData); 58 | galaxyDaemon.waitForUp(); 59 | } 60 | } 61 | 62 | private static void copyFile(File source, File dest) throws IOException { 63 | FileChannel sourceChannel = null; 64 | FileChannel destChannel = null; 65 | try { 66 | sourceChannel = new FileInputStream(source).getChannel(); 67 | destChannel = new FileOutputStream(dest).getChannel(); 68 | destChannel.transferFrom(sourceChannel, 0, sourceChannel.size()); 69 | }finally{ 70 | sourceChannel.close(); 71 | destChannel.close(); 72 | } 73 | } 74 | 75 | /** 76 | * Copies over necessary files for extra tools in Galaxy for testing. 77 | * @param galaxyProperties The GalaxyProperties object. 78 | * @param galaxyRootPath The root path of the Galaxy directory. 79 | * @throws URISyntaxException 80 | * @throws IOException 81 | */ 82 | private static void buildTestTools(GalaxyProperties galaxyProperties, String galaxyRootPath) throws URISyntaxException, IOException { 83 | File collectionExampleToolSource = new File(TestGalaxyInstance.class.getResource( 84 | "collection_list.xml").toURI()); 85 | File testToolConfigSource = new File(TestGalaxyInstance.class.getResource( 86 | "tool_conf_test.xml").toURI()); 87 | 88 | File galaxyRootFile = new File(galaxyRootPath); 89 | 90 | // copy over necessary files for testing custom tools 91 | File collectionExampleToolDirectory = new File(galaxyRootPath, 92 | "tools/collection"); 93 | collectionExampleToolDirectory.mkdirs(); 94 | File collectionExampleToolDestination = 95 | new File(collectionExampleToolDirectory,"collection_list.xml"); 96 | copyFile(collectionExampleToolSource, collectionExampleToolDestination); 97 | 98 | File testToolConfigDestination = new File(galaxyRootFile, "tool_conf_test.xml"); 99 | copyFile(testToolConfigSource, testToolConfigDestination); 100 | 101 | // set configuration file in Galaxy for custom tools 102 | galaxyProperties.setAppProperty("tool_config_file", 103 | "config/tool_conf.xml.sample,config/shed_tool_conf.xml.sample,tool_conf_test.xml"); 104 | } 105 | 106 | @AfterSuite 107 | public static void cleanUpGalaxy() { 108 | if(galaxyDaemon != null) { 109 | galaxyDaemon.stop(); 110 | galaxyDaemon.waitForDown(); 111 | //galaxyDaemon.getBootStrapper().deleteGalaxyRoot(); 112 | } 113 | } 114 | 115 | static GalaxyInstance get() { 116 | final String galaxyInstanceUrl = getTestInstanceUrl(); 117 | final String galaxyApiKey = getTestApiKey(); 118 | return GalaxyInstanceFactory.get(galaxyInstanceUrl, galaxyApiKey, true); 119 | } 120 | 121 | static String getTestApiKey() { 122 | return getProperty("test.galaxy.key", testApiKey); 123 | } 124 | 125 | static String getTestInstanceUrl() { 126 | return getProperty("test.galaxy.instance", testUrl); 127 | } 128 | 129 | static String getProperty(final String key, final String defaultValue) { 130 | String value = defaultValue; 131 | if(System.getProperties().getProperty(key) != null) { 132 | value = System.getProperties().getProperty(key); 133 | } else if(properties.containsKey(key)) { 134 | value = properties.getProperty(key); 135 | } 136 | return value; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/test/java/com/github/jmchilton/blend4j/galaxy/ToolDataTest.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import com.github.jmchilton.blend4j.galaxy.beans.TabularToolDataTable; 6 | import com.sun.jersey.api.client.ClientResponse; 7 | import org.testng.annotations.BeforeMethod; 8 | import org.testng.annotations.Test; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Arrays; 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | public class ToolDataTest { 16 | private static final Logger logger = LoggerFactory.getLogger(ToolDataTest.class); 17 | 18 | private GalaxyInstance instance; 19 | private ToolDataClient client; 20 | 21 | @BeforeMethod 22 | public void init() { 23 | instance = TestGalaxyInstance.get(); 24 | client = instance.getToolDataClient(); 25 | } 26 | 27 | @Test 28 | public void testGetDataTables() { 29 | final List toolDataTables = client.getDataTables(); 30 | assert toolDataTables != null; 31 | assert ! toolDataTables.isEmpty(); 32 | 33 | for (final TabularToolDataTable toolDataTable : toolDataTables) { 34 | assert toolDataTable.getName() != null; 35 | } 36 | } 37 | 38 | @Test 39 | public void testShowDataTable() { 40 | final List toolDataTables = client.getDataTables(); 41 | assert toolDataTables != null; 42 | assert ! toolDataTables.isEmpty(); 43 | 44 | for (final TabularToolDataTable toolDataTable : toolDataTables) { 45 | assert toolDataTable.getName() != null; 46 | TabularToolDataTable dataTable = client.showDataTable(toolDataTable.getName()); 47 | assert dataTable != null; 48 | } 49 | 50 | } 51 | 52 | @Test 53 | public void testShowDataTableRequest() { 54 | final List toolDataTables = client.getDataTables(); 55 | assert toolDataTables != null; 56 | assert ! toolDataTables.isEmpty(); 57 | 58 | for (final TabularToolDataTable toolDataTable : toolDataTables) { 59 | assert toolDataTable.getName() != null; 60 | ClientResponse clientResponse = client.showDataTableRequest(toolDataTable.getName()); 61 | assert clientResponse != null; 62 | assert 200 == clientResponse.getStatus(); 63 | } 64 | 65 | } 66 | 67 | @Test 68 | public void testDeleteDataTableRequest() { 69 | TabularToolDataTable toolDataTable = client.showDataTable("igv_broad_genomes"); 70 | assert toolDataTable != null; 71 | List values = new ArrayList(Arrays.asList("Human hg38", "http://s3.amazonaws.com/igv.broadinstitute.org/genomes/hg38.genome", "hg38")); 72 | ClientResponse clientResponse = client.deleteDataTableRequest(toolDataTable.getName(), values); 73 | assert clientResponse != null; 74 | assert 200 == clientResponse.getStatus(); 75 | logger.debug(clientResponse.toString()); 76 | } 77 | 78 | @Test 79 | public void testReloadDataTableRequest() { 80 | TabularToolDataTable toolDataTable = client.showDataTable("igv_broad_genomes"); 81 | assert toolDataTable != null; 82 | ClientResponse clientResponse = client.reloadDataTableRequest(toolDataTable.getName()); 83 | assert clientResponse != null; 84 | assert 200 == clientResponse.getStatus(); 85 | logger.debug(clientResponse.toString()); 86 | } 87 | 88 | @Test 89 | public void testGetFieldsForValue() { 90 | final TabularToolDataTable igvBroadGenomes = client.showDataTable("igv_broad_genomes"); 91 | assert igvBroadGenomes != null; 92 | final List fieldsList = igvBroadGenomes.getFieldsListForValue("hg38"); 93 | assert fieldsList != null; 94 | final Map fieldsMap = igvBroadGenomes.getFieldsMapForValue("hg38"); 95 | assert fieldsMap != null; 96 | assert fieldsMap.get("value").equals("hg38"); 97 | } 98 | 99 | @Test 100 | public void testGetValues() { 101 | final TabularToolDataTable igvBroadGenomes = client.showDataTable("igv_broad_genomes"); 102 | assert igvBroadGenomes != null; 103 | List values = igvBroadGenomes.getValues(); 104 | assert values.size() == 156; 105 | } 106 | 107 | @Test 108 | public void testGetFieldsForColumn() { 109 | final TabularToolDataTable igvBroadGenomes = client.showDataTable("igv_broad_genomes"); 110 | assert igvBroadGenomes != null; 111 | List values = igvBroadGenomes.getFieldsForColumn("name"); 112 | assert values.size() == 156; 113 | } 114 | 115 | @Test 116 | public void testGetField() { 117 | final TabularToolDataTable igvBroadGenomes = client.showDataTable("igv_broad_genomes"); 118 | assert igvBroadGenomes != null; 119 | String field = igvBroadGenomes.getField("hg38", "name"); 120 | assert field.equals("Human hg38"); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/test/java/com/github/jmchilton/blend4j/galaxy/ToolShedRepositoriesTest.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.beans.InstalledRepository; 4 | import com.github.jmchilton.blend4j.galaxy.beans.InstalledRepository.InstallationStatus; 5 | import com.github.jmchilton.blend4j.galaxy.beans.RepositoryInstall; 6 | import com.github.jmchilton.blend4j.galaxy.beans.RepositoryWorkflow; 7 | import com.github.jmchilton.blend4j.galaxy.beans.Workflow; 8 | import com.sun.jersey.api.client.ClientResponse; 9 | import java.util.List; 10 | import org.testng.annotations.BeforeMethod; 11 | import org.testng.annotations.Test; 12 | 13 | public class ToolShedRepositoriesTest extends IntegrationTest { 14 | private GalaxyInstance instance; 15 | private ToolShedRepositoriesClient reposClient; 16 | 17 | @BeforeMethod 18 | public void init() { 19 | instance = TestGalaxyInstance.get(); 20 | reposClient = instance.getRepositoriesClient(); 21 | } 22 | 23 | //@Test 24 | public void testInstall() { 25 | RepositoryInstall install = new RepositoryInstall(); 26 | install.setChangsetRevision("a38cd98a6b41"); 27 | install.setName("dbbuilder"); 28 | install.setOwner("galaxyp"); 29 | final List repositories = reposClient.installRepository(install); 30 | assert repositories.size() > 0; 31 | } 32 | 33 | //@Test 34 | public void testRepositoryWorkflows() throws InterruptedException { 35 | RepositoryInstall install = new RepositoryInstall(); 36 | install.setInstallRepositoryDependencies(false); 37 | install.setInstallToolDependencies(false); 38 | install.setChangsetRevision("c8261328a9ff"); 39 | install.setName("mmuflr"); 40 | install.setOwner("jjohnson"); 41 | final InstalledRepository repository = reposClient.installRepository(install).get(0); 42 | final String repositoryId = repository.getId(); 43 | while(!reposClient.showRepository(repositoryId).getInstallationStatus().isComplete()) { 44 | System.out.println("Waiting..."); 45 | Thread.sleep(100l); 46 | } 47 | assert reposClient.showRepository(repositoryId).getInstallationStatus().equals(InstallationStatus.INSTALLED); 48 | final List workflows = reposClient.exportedWorkflows(repositoryId); 49 | assert workflows.size() == 3 : "Incorrect number of exported workflows discovered - " + workflows.size(); 50 | final ClientResponse response = reposClient.importWorkflowRequest(repositoryId, workflows.get(0).getIndex()); 51 | assert200(response); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/com/github/jmchilton/blend4j/galaxy/ToolsTest.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import java.io.File; 4 | import java.util.List; 5 | 6 | import org.testng.annotations.BeforeMethod; 7 | import org.testng.annotations.Test; 8 | 9 | import com.github.jmchilton.blend4j.galaxy.ToolsClient.FileUploadRequest; 10 | import com.github.jmchilton.blend4j.galaxy.beans.OutputDataset; 11 | import com.github.jmchilton.blend4j.galaxy.beans.Tool; 12 | import com.github.jmchilton.blend4j.galaxy.beans.ToolExecution; 13 | import com.github.jmchilton.blend4j.galaxy.beans.ToolSection; 14 | import com.sun.jersey.api.client.ClientResponse; 15 | 16 | public class ToolsTest { 17 | private GalaxyInstance instance; 18 | private ToolsClient client; 19 | 20 | @BeforeMethod 21 | public void init() { 22 | instance = TestGalaxyInstance.get(); 23 | client = instance.getToolsClient(); 24 | } 25 | 26 | @Test 27 | public void testUploadRequest() { 28 | final FileUploadRequest request = testRequest(); 29 | final ClientResponse clientResponse = client.uploadRequest(request); 30 | assert clientResponse.getStatus() == 200; 31 | //final String reply = clientResponse.getEntity(String.class); 32 | //assert false: reply; 33 | } 34 | 35 | @Test 36 | public void testUpload() { 37 | final FileUploadRequest request = testRequest(); 38 | final ToolExecution toolExecution = client.upload(request); 39 | final List datasets = toolExecution.getOutputs(); 40 | assert ! datasets.isEmpty(); 41 | assert datasets.get(0).getOutputName().equals("output0"); 42 | 43 | //final ClientResponse clientResponse = client.uploadRequest(request); 44 | //assert clientResponse.getStatus() == 200; 45 | //final String reply = clientResponse.getEntity(String.class); 46 | //assert false: reply; 47 | } 48 | 49 | private FileUploadRequest testRequest() { 50 | final String historyId = TestHelpers.getTestHistoryId(instance); 51 | final File testFile = TestHelpers.getTestFile(); 52 | final FileUploadRequest request = new FileUploadRequest(historyId, testFile); 53 | return request; 54 | } 55 | 56 | @Test 57 | public void testGetTools() { 58 | final List tools = client.getTools(); 59 | assert tools != null; 60 | assert ! tools.isEmpty(); 61 | 62 | for (final ToolSection tool : tools) { 63 | assert tool.getId() != null; 64 | } 65 | } 66 | 67 | @Test 68 | public void testGetToolDetails() { 69 | final List tools = client.getTools(); 70 | // pick an arbitrary tool to get details about. 71 | final Tool toolDetails = client.showTool(tools.iterator().next().getElems().iterator().next().getId()); 72 | 73 | assert toolDetails != null; 74 | assert toolDetails.getName() != null; 75 | assert toolDetails.getVersion() != null; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/test/java/com/github/jmchilton/blend4j/galaxy/UserTest.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.galaxy; 2 | 3 | import com.github.jmchilton.blend4j.galaxy.beans.History; 4 | import com.github.jmchilton.blend4j.galaxy.beans.User; 5 | import com.github.jmchilton.blend4j.galaxy.beans.UserCreate; 6 | import com.sun.jersey.api.client.ClientResponse; 7 | import java.util.UUID; 8 | import org.testng.annotations.BeforeMethod; 9 | import org.testng.annotations.Test; 10 | 11 | public class UserTest { 12 | private final String TEST_PASSWORD = "testpass"; 13 | private GalaxyInstance instance; 14 | private UsersClient client; 15 | 16 | @BeforeMethod 17 | public void init() { 18 | instance = TestGalaxyInstance.get(); 19 | client = instance.getUsersClient(); 20 | } 21 | 22 | @Test 23 | public void testUserCreate() { 24 | final User user = createAndCheckTestUser(); 25 | final String apiKey = client.createApiKey(user.getId()); 26 | } 27 | 28 | @Test 29 | public void testInstanceFromCredentials() { 30 | final User user = createAndCheckTestUser(); 31 | final String url = TestGalaxyInstance.getTestInstanceUrl(); 32 | final GalaxyInstance authedInstance = GalaxyInstanceFactory.getFromCredentials(url, user.getEmail(), TEST_PASSWORD); 33 | final History history = new History(); 34 | history.setName("NewUserHistory"); 35 | final ClientResponse response = authedInstance.getHistoriesClient().createRequest(history); 36 | assert response.getStatus() == 200; 37 | } 38 | 39 | protected User createAndCheckTestUser() { 40 | final UserCreate userCreate = new UserCreate(); 41 | final String username = UUID.randomUUID().toString(); 42 | final String email = username + "@example.com"; 43 | userCreate.setEmail(email); 44 | userCreate.setUsername(username); 45 | userCreate.setPassword(TEST_PASSWORD); 46 | 47 | final User user = client.createUser(userCreate); 48 | assert user.getEmail().equals(email); 49 | assert user.getUsername().equals(username); 50 | return user; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/com/github/jmchilton/blend4j/toolshed/RepositoriesClientTest.java: -------------------------------------------------------------------------------- 1 | package com.github.jmchilton.blend4j.toolshed; 2 | 3 | import com.github.jmchilton.blend4j.toolshed.beans.Repository; 4 | import com.github.jmchilton.blend4j.toolshed.beans.RepositoryDetails; 5 | import com.github.jmchilton.blend4j.toolshed.beans.RepositoryRevision; 6 | import com.sun.jersey.api.client.ClientResponse; 7 | import java.util.List; 8 | import org.testng.annotations.BeforeMethod; 9 | import org.testng.annotations.Test; 10 | 11 | public class RepositoriesClientTest { 12 | private static final Repository DBBUILDER_REPOSITORY = new Repository("galaxyp", "dbbuilder"); 13 | private ToolShedInstance instance; 14 | private RepositoriesClient reposClient; 15 | 16 | @BeforeMethod 17 | public void init() { 18 | instance = ToolShedInstanceFactory.getMainToolShedInstance(); 19 | reposClient = instance.getRepositoriesClient(); 20 | } 21 | 22 | @Test 23 | public void testGetTools() { 24 | final List tools = reposClient.getRepositories(); 25 | boolean found = false; 26 | for(final RepositoryDetails tool : tools) { 27 | if(tool.getName().equals("abyss_tool")) { 28 | found = true; 29 | break; 30 | } 31 | } 32 | assert found; 33 | } 34 | 35 | @Test 36 | public void testGetInstallableRevisions() { 37 | final List revisions = reposClient.getInstallableRevisions(DBBUILDER_REPOSITORY); 38 | assert revisions.size() > 1; 39 | assert revisions.get(0).equals("abbd37e8bd14"); 40 | } 41 | 42 | @Test 43 | public void testGetLatestRepositoryRevision() { 44 | final RepositoryRevision revision = RepositoryUtils.getLatestRepositoryRevision(reposClient, DBBUILDER_REPOSITORY); 45 | final ClientResponse response = reposClient.getRepositoryRevisionInstallInfoRequest(revision); 46 | assert response.getStatus() == 200 : response.getStatus(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/resources/com/github/jmchilton/blend4j/galaxy/TestWorkflow1.ga: -------------------------------------------------------------------------------- 1 | { 2 | "a_galaxy_workflow": "true", 3 | "annotation": "", 4 | "format-version": "0.1", 5 | "name": "TestWorkflow1", 6 | "steps": { 7 | "0": { 8 | "annotation": "", 9 | "id": 0, 10 | "input_connections": {}, 11 | "inputs": [ 12 | { 13 | "description": "", 14 | "name": "WorkflowInput1" 15 | } 16 | ], 17 | "name": "Input dataset", 18 | "outputs": [], 19 | "position": { 20 | "left": 199.55555772781372, 21 | "top": 200.66666460037231 22 | }, 23 | "tool_errors": null, 24 | "tool_id": null, 25 | "tool_state": "{\"name\": \"WorkflowInput1\"}", 26 | "tool_version": null, 27 | "type": "data_input", 28 | "uuid": "3232b621-1c0e-4449-a0b5-1067bf798d56", 29 | "user_outputs": [] 30 | }, 31 | "1": { 32 | "annotation": "", 33 | "id": 1, 34 | "input_connections": {}, 35 | "inputs": [ 36 | { 37 | "description": "", 38 | "name": "WorkflowInput2" 39 | } 40 | ], 41 | "name": "Input dataset", 42 | "outputs": [], 43 | "position": { 44 | "left": 206.22221422195435, 45 | "top": 327.33335161209106 46 | }, 47 | "tool_errors": null, 48 | "tool_id": null, 49 | "tool_state": "{\"name\": \"WorkflowInput2\"}", 50 | "tool_version": null, 51 | "type": "data_input", 52 | "uuid": "ea7a0edd-37ba-4fc6-8e23-496e33e36868", 53 | "user_outputs": [] 54 | }, 55 | "2": { 56 | "annotation": "", 57 | "id": 2, 58 | "input_connections": { 59 | "input1": { 60 | "id": 0, 61 | "output_name": "output" 62 | }, 63 | "queries_0|input2": { 64 | "id": 1, 65 | "output_name": "output" 66 | } 67 | }, 68 | "inputs": [], 69 | "name": "Concatenate datasets", 70 | "outputs": [ 71 | { 72 | "name": "out_file1", 73 | "type": "input" 74 | } 75 | ], 76 | "position": { 77 | "left": 419.33335876464844, 78 | "top": 200.44446563720703 79 | }, 80 | "post_job_actions": {}, 81 | "tool_errors": null, 82 | "tool_id": "cat1", 83 | "tool_state": "{\"__page__\": 0, \"__rerun_remap_job_id__\": null, \"input1\": \"null\", \"chromInfo\": \"\\\"/home/john/workspace/galaxy-central/tool-data/shared/ucsc/chrom/?.len\\\"\", \"queries\": \"[{\\\"input2\\\": null, \\\"__index__\\\": 0}]\"}", 84 | "tool_version": "1.0.0", 85 | "type": "tool", 86 | "uuid": "6fa1b23b-51af-4b4f-9135-35cf151c5a3c", 87 | "user_outputs": [] 88 | } 89 | }, 90 | "uuid": "27d4c823-4dd9-4495-9ff4-a3df6b554535" 91 | } -------------------------------------------------------------------------------- /src/test/resources/com/github/jmchilton/blend4j/galaxy/TestWorkflowCollectionList.ga: -------------------------------------------------------------------------------- 1 | { 2 | "a_galaxy_workflow": "true", 3 | "annotation": "", 4 | "format-version": "0.1", 5 | "name": "TestWorkflowCollectionList", 6 | "steps": { 7 | "0": { 8 | "annotation": "", 9 | "id": 0, 10 | "input_connections": {}, 11 | "inputs": [ 12 | { 13 | "description": "", 14 | "name": "input_list" 15 | } 16 | ], 17 | "name": "Input dataset collection", 18 | "outputs": [], 19 | "position": { 20 | "left": 377.5, 21 | "top": 317.5 22 | }, 23 | "tool_errors": null, 24 | "tool_id": null, 25 | "tool_state": "{\"collection_type\": \"list\", \"name\": \"input_list\"}", 26 | "tool_version": null, 27 | "type": "data_collection_input", 28 | "uuid": "73bb50c5-10fa-4f6c-8b12-aafed369689a", 29 | "user_outputs": [] 30 | }, 31 | "1": { 32 | "annotation": "", 33 | "id": 1, 34 | "input_connections": { 35 | "in": { 36 | "id": 0, 37 | "output_name": "output" 38 | } 39 | }, 40 | "inputs": [], 41 | "name": "collection_list", 42 | "outputs": [ 43 | { 44 | "name": "out", 45 | "type": "txt" 46 | } 47 | ], 48 | "position": { 49 | "left": 592.5, 50 | "top": 312.5 51 | }, 52 | "post_job_actions": {}, 53 | "tool_errors": null, 54 | "tool_id": "collection_list", 55 | "tool_state": "{\"__page__\": 0, \"__rerun_remap_job_id__\": null, \"in\": \"null\"}", 56 | "tool_version": "0.1.0", 57 | "type": "tool", 58 | "uuid": "28b555a6-eb27-491a-8515-7ec9c447f147", 59 | "user_outputs": [] 60 | } 61 | }, 62 | "uuid": "c5675c83-2bbe-44bd-9935-5f41812a66f0" 63 | } -------------------------------------------------------------------------------- /src/test/resources/com/github/jmchilton/blend4j/galaxy/TestWorkflowRandomlines.ga: -------------------------------------------------------------------------------- 1 | { 2 | "a_galaxy_workflow": "true", 3 | "annotation": "Random Lines", 4 | "format-version": "0.1", 5 | "name": "TestWorkflowRandomlines", 6 | "steps": { 7 | "0": { 8 | "annotation": "", 9 | "id": 0, 10 | "input_connections": {}, 11 | "inputs": [ 12 | { 13 | "description": "", 14 | "name": "Input Dataset" 15 | } 16 | ], 17 | "name": "Input dataset", 18 | "outputs": [], 19 | "position": { 20 | "left": 191, 21 | "top": 200 22 | }, 23 | "tool_errors": null, 24 | "tool_id": null, 25 | "tool_state": "{\"name\": \"Input Dataset\"}", 26 | "tool_version": null, 27 | "type": "data_input", 28 | "uuid": "33b12960-5cb4-40b2-ad22-b32467c1ca52", 29 | "user_outputs": [] 30 | }, 31 | "1": { 32 | "annotation": "", 33 | "id": 1, 34 | "input_connections": { 35 | "input": { 36 | "id": 0, 37 | "output_name": "output" 38 | } 39 | }, 40 | "inputs": [], 41 | "name": "Select random lines", 42 | "outputs": [ 43 | { 44 | "name": "out_file1", 45 | "type": "input" 46 | } 47 | ], 48 | "position": { 49 | "left": 432.5, 50 | "top": 254 51 | }, 52 | "post_job_actions": {}, 53 | "tool_errors": null, 54 | "tool_id": "random_lines1", 55 | "tool_state": "{\"input\": \"null\", \"seed_source\": \"{\\\"__current_case__\\\": 0, \\\"seed_source_selector\\\": \\\"no_seed\\\"}\", \"__rerun_remap_job_id__\": null, \"num_lines\": \"\\\"5\\\"\", \"__page__\": 0}", 56 | "tool_version": "2.0.1", 57 | "type": "tool", 58 | "uuid": "09d18c95-4361-4eec-8c09-19d3c4b9cfb3", 59 | "user_outputs": [] 60 | }, 61 | "2": { 62 | "annotation": "", 63 | "id": 2, 64 | "input_connections": { 65 | "input": { 66 | "id": 1, 67 | "output_name": "out_file1" 68 | } 69 | }, 70 | "inputs": [], 71 | "name": "Select random lines", 72 | "outputs": [ 73 | { 74 | "name": "out_file1", 75 | "type": "input" 76 | } 77 | ], 78 | "position": { 79 | "left": 690.5, 80 | "top": 235 81 | }, 82 | "post_job_actions": {}, 83 | "tool_errors": null, 84 | "tool_id": "random_lines1", 85 | "tool_state": "{\"input\": \"null\", \"seed_source\": \"{\\\"__current_case__\\\": 0, \\\"seed_source_selector\\\": \\\"no_seed\\\"}\", \"__rerun_remap_job_id__\": null, \"num_lines\": \"\\\"2\\\"\", \"__page__\": 0}", 86 | "tool_version": "2.0.1", 87 | "type": "tool", 88 | "uuid": "0a55f2f4-09e3-41e4-aa56-7aabe50b7246", 89 | "user_outputs": [] 90 | } 91 | }, 92 | "uuid": "bec8e849-ab54-4f6a-a693-f3ed9de0f817" 93 | } -------------------------------------------------------------------------------- /src/test/resources/com/github/jmchilton/blend4j/galaxy/collection_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | cat #for $f in $in# ${f} #end for# >> $out; 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/com/github/jmchilton/blend4j/galaxy/tool_conf_test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Direct log messages to stdout 2 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | log4j.appender.stdout.Target=System.out 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%d{DATE} %5p %c{1}:%L - %m%n 6 | 7 | # Root logger option 8 | log4j.rootLogger=ERROR, stdout 9 | # Debug logging for galaxybootstrap classes 10 | log4j.logger.com.github.jmchilton.galaxybootstrap=INFO 11 | -------------------------------------------------------------------------------- /ssl/InstallCert$SavingTrustManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galaxyproject/blend4j/2201df98a54f8231f26b3594d14d920be2abfa25/ssl/InstallCert$SavingTrustManager.class -------------------------------------------------------------------------------- /ssl/InstallCert.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galaxyproject/blend4j/2201df98a54f8231f26b3594d14d920be2abfa25/ssl/InstallCert.class -------------------------------------------------------------------------------- /ssl/SSLPoke.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galaxyproject/blend4j/2201df98a54f8231f26b3594d14d920be2abfa25/ssl/SSLPoke.class --------------------------------------------------------------------------------