Make statistics in VC list configurable (default: false)

Default in kustvakt.conf
vc.list.statistics.enabled = false

Change-Id: I685c3a17128129e652de7e639c67e73196fbe4ad
diff --git a/Changes b/Changes
index 2d89892..8cdea37 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 # version 0.79.1
-- Bug fixes & Spring 6.2.11 upgrade(kupietz)
+
+- Bug fixes & Spring 6.2.11 upgrade (kupietz)
+- Migrate to Hibernate 7x (kupietz)
+- Make statistics in VC list configurable (default: false)
 
 # version 0.79
 
diff --git a/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
index d606c76..47fcf76 100644
--- a/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
@@ -66,6 +66,7 @@
     private String namedVCPath;
 
     private boolean createInitialSuperClient;
+    private boolean vcListStatisticsEnabled;
 
     public FullConfiguration (Properties properties) throws Exception {
         super(properties);
@@ -96,6 +97,8 @@
 
         setMaxNumberOfUserQueries(Integer.parseInt(
                 properties.getProperty("max.user.persistent.queries", "20")));
+		setVcListStatisticsEnabled(Boolean.valueOf(properties.getProperty(
+				"vc.list.statistics.enabled", "false")));
     }
 
     private void setSecurityConfiguration (Properties properties)
@@ -427,4 +430,14 @@
         this.maxNumberOfUserQueries = maxNumberOfUserQueries;
     }
 
+	public boolean isVcListStatisticsEnabled () {
+		return vcListStatisticsEnabled;
+	}
+
+	public void setVcListStatisticsEnabled (boolean vcListStatisticsEnabled) {
+		this.vcListStatisticsEnabled = vcListStatisticsEnabled;
+	}
+
+	
+
 }
diff --git a/src/main/java/de/ids_mannheim/korap/service/QueryService.java b/src/main/java/de/ids_mannheim/korap/service/QueryService.java
index f329ab0..5a8bbf7 100644
--- a/src/main/java/de/ids_mannheim/korap/service/QueryService.java
+++ b/src/main/java/de/ids_mannheim/korap/service/QueryService.java
@@ -146,24 +146,32 @@
         Iterator<QueryDO> i = queryList.iterator();
         while (i.hasNext()) {
             query = i.next();
-            String json = "";
-            String statistics = null;
-			if (queryType.equals(QueryType.VIRTUAL_CORPUS)) {
-				if (query.isCached()) {
-					List<String> cqList = new ArrayList<>(1);
-					cqList.add("referTo " + query.getName());
-					json = buildKoralQueryFromCorpusQuery(cqList);
-				}
-				else {
-					json = query.getKoralQuery();
-				}
-				statistics = krill.getStatistics(json);
-			}
+            String statistics = computeStatisticsForVC(query, queryType);
 			QueryDto dto = converter.createQueryDto(query, statistics);
 			dtos.add(dto);
 		}
 		return dtos;
     }
+    
+	private String computeStatisticsForVC (QueryDO query, QueryType queryType)
+			throws KustvaktException {
+		if (config.isVcListStatisticsEnabled() && 
+				queryType.equals(QueryType.VIRTUAL_CORPUS)) {		
+    		String json = "";
+    		if (query.isCached()) {
+    			List<String> cqList = new ArrayList<>(1);
+    			cqList.add("referTo " + query.getName());
+    			json = buildKoralQueryFromCorpusQuery(cqList);
+    		}
+    		else {
+    			json = query.getKoralQuery();
+    		}
+    		return krill.getStatistics(json);
+		}
+		else {
+			return null;
+		}
+	}
 
     public void deleteQueryByName (String deletedBy, String queryName,
             String createdBy, QueryType type) throws KustvaktException {
diff --git a/src/main/resources/kustvakt.conf b/src/main/resources/kustvakt.conf
index e45ea32..61cad26 100644
--- a/src/main/resources/kustvakt.conf
+++ b/src/main/resources/kustvakt.conf
@@ -37,6 +37,9 @@
 default.foundry.morphology = marmot
 default.foundry.surface = base
 
+# Virtual corpus and queries
+max.user.persistent.queries = 5
+vc.list.statistics.enabled = false
 
 # Availability regex only support |
 # It should be removed/commented when the data doesn't contain availability field.
diff --git a/src/test/resources/kustvakt-test.conf b/src/test/resources/kustvakt-test.conf
index 13fd337..f50c4ab 100644
--- a/src/test/resources/kustvakt-test.conf
+++ b/src/test/resources/kustvakt-test.conf
@@ -49,6 +49,8 @@
 # Virtual corpus and queries
 max.user.persistent.queries = 5
 max.token.context.size = 40
+# default false
+vc.list.statistics.enabled = true
 
 # Availability regex only support |
 # It should be removed/commented when the data doesn't contain availability field.