You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2014/09/12 22:35:13 UTC

svn commit: r1624638 - /uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/sort/ServicesSortCache.java

Author: degenaro
Date: Fri Sep 12 20:35:12 2014
New Revision: 1624638

URL: http://svn.apache.org/r1624638
Log:
UIMA-4009 DUCC Web Server (WS) transform Services page "Start" buttons into "Enable" buttons

Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/sort/ServicesSortCache.java

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/sort/ServicesSortCache.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/sort/ServicesSortCache.java?rev=1624638&r1=1624637&r2=1624638&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/sort/ServicesSortCache.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/registry/sort/ServicesSortCache.java Fri Sep 12 20:35:12 2014
@@ -23,11 +23,19 @@ import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.TreeMap;
 
+import org.apache.uima.ducc.common.persistence.services.IStateServices;
+import org.apache.uima.ducc.common.utils.DuccLogger;
+import org.apache.uima.ducc.common.utils.DuccLoggerComponents;
+import org.apache.uima.ducc.common.utils.id.DuccId;
 import org.apache.uima.ducc.ws.registry.ServicesRegistryMap;
 import org.apache.uima.ducc.ws.registry.ServicesRegistryMapPayload;
 
 public class ServicesSortCache {
 	
+	
+	private static DuccLogger duccLogger = DuccLoggerComponents.getWsLogger(ServicesSortCache.class.getName());
+	private static DuccId jobid = null;
+	
 	private static ServicesSortCache instance = new ServicesSortCache();
 	
 	public static ServicesSortCache getInstance() {
@@ -48,6 +56,35 @@ public class ServicesSortCache {
 		map = mapRevised;
 	}
 	
+	private void enabled(int id, boolean bool) {
+		String location = "enabled";
+		try {
+			for(Entry<SortableService, IServiceAdapter> entry : map.entrySet()) {
+				IServiceAdapter payload = entry.getValue();
+				Properties meta = payload.getMeta();
+				String key = IStateServices.numeric_id;
+				String value = meta.getProperty(key);
+				int numeric_id = Integer.parseInt(value);
+				if(numeric_id == id) {
+					meta.setProperty(IStateServices.enabled, Boolean.toString(bool));
+					payload.setMeta(meta);
+					break;
+				}
+			}
+		}
+		catch(Exception e) {
+			duccLogger.error(location, jobid, e);
+		}
+	}
+	
+	public void setDisabled(int id) {
+		enabled(id, false);
+	}
+	
+	public void setEnabled(int id) {
+		enabled(id, true);
+	}
+	
 	public int size() {
 		return map.size();
 	}