Search in sources :

Example 6 with OncoTreeNode

use of org.mskcc.oncotree.topbraid.OncoTreeNode in project oncotree by cBioPortal.

the class OncoTreePersistentCache method getOncoTreeNodesFromPersistentCacheBackup.

/*
        All methods using the backup cache manager should be synchronized on the same object.
        In this case, we synchronize on the instance of this class.  This is so only one
        thread is modifying the caches defined in BACKUP_CACHE_CONFIG_FILENAME at a time.
        These methods close all caches known to the cacheManager.  You wouldn't want to
        be using a cache that another method (or the same method) is closing.
    */
// retrieve cache TopBraid responses from backup EHCache location (and re-populate default EHCache locatin)
@Cacheable(value = "oncoTreeNodesEHCache", key = "#version.version", unless = "#result==null")
private synchronized ArrayList<OncoTreeNode> getOncoTreeNodesFromPersistentCacheBackup(Version version) throws Exception {
    CacheManager cacheManager = null;
    Cache<String, ArrayList<OncoTreeNode>> cache = null;
    ArrayList<OncoTreeNode> oncoTreeNodes = null;
    try {
        cacheManager = getCacheManager(BACKUP_CACHE_CONFIG_FILENAME);
        cache = cacheManager.getCache(ONCOTREE_NODES_CACHE);
        oncoTreeNodes = cache.get(version.getVersion());
    } finally {
        if (cacheManager != null) {
            // closes all caches it knows about
            cacheManager.close();
        }
    }
    return oncoTreeNodes;
}
Also used : ArrayList(java.util.ArrayList) CacheManager(javax.cache.CacheManager) OncoTreeNode(org.mskcc.oncotree.topbraid.OncoTreeNode) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 7 with OncoTreeNode

use of org.mskcc.oncotree.topbraid.OncoTreeNode in project oncotree by cBioPortal.

the class OncotreeTestConfig method setupOncotreeRepositoryMockResponseHistoryChange.

private ArrayList<OncoTreeNode> setupOncotreeRepositoryMockResponseHistoryChange() {
    ArrayList<OncoTreeNode> tmpOncoTreeRepositoryMockResponseHistoryChange = new ArrayList<>();
    for (OncoTreeNode oncotreeNode : oncoTreeRepositoryMockResponse) {
        OncoTreeNode newOncotreeNode = new OncoTreeNode(oncotreeNode);
        // SEZS will be in the history of SS
        if ("SEZS".equals(newOncotreeNode.getCode())) {
            newOncotreeNode.setCode("SS");
        }
        // add revocations
        if ("URMM".equals(newOncotreeNode.getCode())) {
            newOncotreeNode.setRevocations("ONC000503");
        }
        tmpOncoTreeRepositoryMockResponseHistoryChange.add(newOncotreeNode);
    }
    OncoTreeNode newOncotreeNode = new OncoTreeNode();
    newOncotreeNode.setURI("http://data.mskcc.org/ontologies/oncotree/ONC000932");
    newOncotreeNode.setCode("CLLSLL");
    newOncotreeNode.setName("DLBCL Associated with Chronic Inflammation");
    newOncotreeNode.setMainType("Mature B-Cell Neoplasms");
    newOncotreeNode.setColor("LimeGreen");
    newOncotreeNode.setParentCode("BCL");
    newOncotreeNode.setPrecursors("ONC000413 ONC000820");
    tmpOncoTreeRepositoryMockResponseHistoryChange.add(newOncotreeNode);
    return tmpOncoTreeRepositoryMockResponseHistoryChange;
}
Also used : OncoTreeNode(org.mskcc.oncotree.topbraid.OncoTreeNode)

Aggregations

OncoTreeNode (org.mskcc.oncotree.topbraid.OncoTreeNode)7 TumorType (org.mskcc.oncotree.model.TumorType)3 MSKConcept (org.mskcc.oncotree.crosswalk.MSKConcept)2 InvalidOncoTreeDataException (org.mskcc.oncotree.error.InvalidOncoTreeDataException)2 Version (org.mskcc.oncotree.model.Version)2 TopBraidException (org.mskcc.oncotree.topbraid.TopBraidException)2 ArrayList (java.util.ArrayList)1 CacheManager (javax.cache.CacheManager)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 Scheduled (org.springframework.scheduling.annotation.Scheduled)1