Search in sources :

Example 11 with Version

use of org.mskcc.oncotree.model.Version in project oncotree by cBioPortal.

the class OncotreeTestConfig method setupMockVersion.

private Version setupMockVersion() {
    Version mockVersion = new Version();
    mockVersion = new Version();
    mockVersion.setVersion("mockversion");
    return mockVersion;
}
Also used : Version(org.mskcc.oncotree.model.Version)

Example 12 with Version

use of org.mskcc.oncotree.model.Version in project oncotree by cBioPortal.

the class MainTypesApi method mainTypesGet.

@ApiOperation(value = "Return all available main tumor types.", notes = "")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Nested tumor types object"), @ApiResponse(code = 404, message = "Could not find maintypes"), @ApiResponse(code = 503, message = "Required data source unavailable") })
@RequestMapping(value = "", produces = { "application/json" }, method = RequestMethod.GET)
public Iterable<String> mainTypesGet(@ApiParam(value = "The version of tumor types. For example, " + VersionUtil.DEFAULT_VERSION + ". Please see the versions api documentation for released versions.") @RequestParam(value = "version", required = false) String version) {
    Version v = (version == null) ? versionUtil.getDefaultVersion() : versionUtil.getVersion(version);
    Map<String, TumorType> tumorTypes = cacheUtil.getTumorTypesByVersion(v);
    Set<TumorType> tumorTypesSet = tumorTypesUtil.flattenTumorTypes(tumorTypes, version);
    return mainTypesUtil.getMainTypesByTumorTypes(tumorTypesSet);
}
Also used : TumorType(org.mskcc.oncotree.model.TumorType) Version(org.mskcc.oncotree.model.Version) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with Version

use of org.mskcc.oncotree.model.Version in project oncotree by cBioPortal.

the class OncoTreePersistentCache method getOncoTreeVersionsFromPersistentCacheBackup.

@Cacheable(value = "oncoTreeVersionsEHCache", key = "#root.target.ONCOTREE_VERSIONS_CACHE_KEY", unless = "#result==null")
private synchronized ArrayList<Version> getOncoTreeVersionsFromPersistentCacheBackup() throws Exception {
    CacheManager cacheManager = null;
    Cache<String, ArrayList<Version>> cache = null;
    ArrayList<Version> versions = null;
    try {
        cacheManager = getCacheManager(BACKUP_CACHE_CONFIG_FILENAME);
        cache = cacheManager.getCache(ONCOTREE_VERSIONS_CACHE);
        versions = cache.get(ONCOTREE_VERSIONS_CACHE_KEY);
    } finally {
        if (cacheManager != null) {
            // closes all caches it knows about
            cacheManager.close();
        }
    }
    return versions;
}
Also used : Version(org.mskcc.oncotree.model.Version) ArrayList(java.util.ArrayList) CacheManager(javax.cache.CacheManager) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 14 with Version

use of org.mskcc.oncotree.model.Version in project oncotree by cBioPortal.

the class VersionUtilTest method testEmptyVersionQuery.

@Test(expected = InvalidVersionException.class)
public void testEmptyVersionQuery() throws Exception {
    String testVersionName = "";
    Version returnedVersion = versionUtil.getVersion(testVersionName);
    fail("expected exception (InvalidVersionException) did not get thrown");
}
Also used : Version(org.mskcc.oncotree.model.Version) Test(org.junit.Test)

Example 15 with Version

use of org.mskcc.oncotree.model.Version in project oncotree by cBioPortal.

the class VersionUtilTest method testSuccessfulVersionQuery.

@Test
public void testSuccessfulVersionQuery() throws Exception {
    String testVersionName = expectedVersionMap.keySet().iterator().next();
    Version expectedVersion = expectedVersionMap.get(testVersionName);
    Version returnedVersion = versionUtil.getVersion(testVersionName);
    int failureCount = 0;
    StringBuilder failureReport = new StringBuilder();
    failureCount = failureCount + failuresInReturnedVersionComparison(testVersionName, expectedVersion, returnedVersion, failureReport);
    if (failureCount > 0) {
        fail(Integer.toString(failureCount) + " failed test conditions. Details follow... " + failureReport.toString());
    }
    return;
}
Also used : Version(org.mskcc.oncotree.model.Version) Test(org.junit.Test)

Aggregations

Version (org.mskcc.oncotree.model.Version)15 Test (org.junit.Test)5 TumorType (org.mskcc.oncotree.model.TumorType)3 Bean (org.springframework.context.annotation.Bean)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 OncoTreeNode (org.mskcc.oncotree.topbraid.OncoTreeNode)2 TopBraidException (org.mskcc.oncotree.topbraid.TopBraidException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 InputStream (java.io.InputStream)1 Deprecated (java.lang.Deprecated)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CacheManager (javax.cache.CacheManager)1 InvalidOncoTreeDataException (org.mskcc.oncotree.error.InvalidOncoTreeDataException)1 InvalidVersionException (org.mskcc.oncotree.error.InvalidVersionException)1 FailedCacheRefreshException (org.mskcc.oncotree.utils.FailedCacheRefreshException)1 Cacheable (org.springframework.cache.annotation.Cacheable)1 EventListener (org.springframework.context.event.EventListener)1 InputStreamResource (org.springframework.core.io.InputStreamResource)1