From c1d14335ee42f1e42212cf1f6ae8893418105707 Mon Sep 17 00:00:00 2001
From: sherzinger <sascha.herzinger@uni.lu>
Date: Mon, 12 Nov 2018 08:38:38 +0100
Subject: [PATCH] Fixed reactome module

---
 .../mapviewer/annotation/cache/ApplicationLevelCache.java | 2 ++
 .../lcsb/mapviewer/annotation/cache/GeneralCache.java     | 7 +++++--
 .../mapviewer/annotation/cache/CachableInterfaceTest.java | 4 ++--
 .../lcsb/mapviewer/annotation/cache/GeneralCacheTest.java | 2 +-
 .../annotation/cache/GeneralCacheWithExclusionTest.java   | 8 ++++----
 .../lcsb/mapviewer/persist/SpringApplicationContext.java  | 1 +
 .../lcsb/mapviewer/reactome/SpringReactomeConfig.java     | 3 +++
 7 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/ApplicationLevelCache.java b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/ApplicationLevelCache.java
index 988858a11d..67aa9ff6f0 100644
--- a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/ApplicationLevelCache.java
+++ b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/ApplicationLevelCache.java
@@ -4,6 +4,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.log4j.Logger;
+import org.springframework.stereotype.Service;
 import org.w3c.dom.Node;
 
 import lcsb.mapviewer.common.Configuration;
@@ -19,6 +20,7 @@ import lcsb.mapviewer.model.cache.CacheType;
  * @author Piotr Gawron
  * 
  */
+@Service
 public final class ApplicationLevelCache extends XmlParser implements QueryCacheInterface {
 
   /**
diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/GeneralCache.java b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/GeneralCache.java
index e82c710982..cd26787060 100644
--- a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/GeneralCache.java
+++ b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/GeneralCache.java
@@ -2,6 +2,7 @@ package lcsb.mapviewer.annotation.cache;
 
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.w3c.dom.Node;
@@ -31,7 +32,7 @@ public class GeneralCache implements GeneralCacheInterface {
    * Application level cache. More information can be found
    * {@link ApplicationLevelCache here}.
    */
-  private QueryCacheInterface cache1 = ApplicationLevelCache.getInstance();
+  private QueryCacheInterface cache1;
 
   /**
    * Database level cache. More information can be found
@@ -43,7 +44,9 @@ public class GeneralCache implements GeneralCacheInterface {
    * Constructor
    */
   @Autowired
-  public GeneralCache(QueryCacheInterface cache2) {
+  public GeneralCache(@Qualifier(value = "applicationLevelCache") QueryCacheInterface cache1,
+                      @Qualifier(value = "permanentDatabaseLevelCache") QueryCacheInterface cache2) {
+    this.cache1 = cache1;
     this.cache2 = cache2;
   }
 
diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/CachableInterfaceTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/CachableInterfaceTest.java
index b8f7bfebfd..d0098feb37 100644
--- a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/CachableInterfaceTest.java
+++ b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/CachableInterfaceTest.java
@@ -59,7 +59,7 @@ public class CachableInterfaceTest extends AnnotationTestFunctions {
 			CacheTypeDao mock = Mockito.mock(CacheTypeDao.class);
 			when(mock.getByClassName(anyString())).thenReturn(new CacheType());
 			ci.setCacheTypeDao(mock);
-			ci.setCache(new GeneralCache(null));
+			ci.setCache(new GeneralCache(null, null));
 			
 			String cacheKey = "https://www.google.com/";
 			String result = ci.getWebPageContent(cacheKey);
@@ -82,7 +82,7 @@ public class CachableInterfaceTest extends AnnotationTestFunctions {
 			ci.setCacheTypeDao(mock);
 			
 			String xml = "<xml><child/></xml>";
-			ci.setCache(new GeneralCache(null));
+			ci.setCache(new GeneralCache(null, null));
 			ci.setCacheNode("id", super.getNodeFromXmlString(xml));
 			
 			Node node = ci.getCacheNode("id");
diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheTest.java
index 3a790cba66..b001cceb2f 100644
--- a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheTest.java
+++ b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheTest.java
@@ -19,7 +19,7 @@ import lcsb.mapviewer.model.cache.CacheType;
 public class GeneralCacheTest extends AnnotationTestFunctions {
 	Logger															 logger	= Logger.getLogger(GeneralCacheTest.class);
 
-	GeneralCache												 cache	= new GeneralCache(null);
+	GeneralCache												 cache	= new GeneralCache(null, null);
 
 	@Autowired
 	PermanentDatabaseLevelCacheInterface databaseLevelCache;
diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheWithExclusionTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheWithExclusionTest.java
index 4d3164868e..f822ff5ace 100644
--- a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheWithExclusionTest.java
+++ b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheWithExclusionTest.java
@@ -44,7 +44,7 @@ public class GeneralCacheWithExclusionTest extends AnnotationTestFunctions {
 	public void testExclusion() throws Exception {
 		try {
 			CacheType type = new CacheType();
-			GeneralCache cache = new GeneralCache(null);
+			GeneralCache cache = new GeneralCache(null, null);
 			cache.setCache2(ApplicationLevelCache.getInstance());
 			GeneralCacheWithExclusion cacheWithExclusion = new GeneralCacheWithExclusion(cache, 2);
 
@@ -67,7 +67,7 @@ public class GeneralCacheWithExclusionTest extends AnnotationTestFunctions {
 	public void testClear() throws Exception {
 		try {
 			CacheType type = new CacheType();
-			GeneralCache cache = new GeneralCache(null);
+			GeneralCache cache = new GeneralCache(null, null);
 			cache.setCache2(ApplicationLevelCache.getInstance());
 			GeneralCacheWithExclusion cacheWithExclusion = new GeneralCacheWithExclusion(cache, 0);
 
@@ -90,7 +90,7 @@ public class GeneralCacheWithExclusionTest extends AnnotationTestFunctions {
 	public void testRemove() throws Exception {
 		try {
 			CacheType type = new CacheType();
-			GeneralCache cache = new GeneralCache(null);
+			GeneralCache cache = new GeneralCache(null, null);
 			cache.setCache2(ApplicationLevelCache.getInstance());
 			GeneralCacheWithExclusion cacheWithExclusion = new GeneralCacheWithExclusion(cache, 0);
 
@@ -114,7 +114,7 @@ public class GeneralCacheWithExclusionTest extends AnnotationTestFunctions {
 	public void testInvalidate() throws Exception {
 		try {
 			CacheType type = new CacheType();
-			GeneralCache cache = new GeneralCache(null);
+			GeneralCache cache = new GeneralCache(null, null);
 			cache.setCache2(ApplicationLevelCache.getInstance());
 			GeneralCacheWithExclusion cacheWithExclusion = new GeneralCacheWithExclusion(cache, 0);
 
diff --git a/persist/src/main/java/lcsb/mapviewer/persist/SpringApplicationContext.java b/persist/src/main/java/lcsb/mapviewer/persist/SpringApplicationContext.java
index e2b982e3c7..4b8aa0a9d2 100644
--- a/persist/src/main/java/lcsb/mapviewer/persist/SpringApplicationContext.java
+++ b/persist/src/main/java/lcsb/mapviewer/persist/SpringApplicationContext.java
@@ -53,6 +53,7 @@ public class SpringApplicationContext implements ApplicationContextAware {
 	 * @return an Object reference to the named bean.
 	 */
 	public static Object getBean(String beanName) {
+		beanName = beanName.substring(0, 1).toLowerCase() + beanName.substring(1);
 		return context.getBean(beanName);
 	}
 	
diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/SpringReactomeConfig.java b/reactome/src/main/java/lcsb/mapviewer/reactome/SpringReactomeConfig.java
index 79d43abf5e..d69c28be33 100644
--- a/reactome/src/main/java/lcsb/mapviewer/reactome/SpringReactomeConfig.java
+++ b/reactome/src/main/java/lcsb/mapviewer/reactome/SpringReactomeConfig.java
@@ -1,9 +1,12 @@
 package lcsb.mapviewer.reactome;
 
+import lcsb.mapviewer.annotation.SpringAnnotationConfig;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
 
 @Configuration
+@Import({SpringAnnotationConfig.class})
 @ComponentScan(basePackages = {"lcsb.mapviewer.reactome"})
 public class SpringReactomeConfig {
 
-- 
GitLab