Author: degenaro
Date: Sat Jun  8 10:09:03 2013
New Revision: 1490941

URL: http://svn.apache.org/r1490941
Log:
UIMA-2724 DUCC webserver (WS) specification displays should make clear 
difference between user specified and system default values

Modified:
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccFile.java
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccFile.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccFile.java?rev=1490941&r1=1490940&r2=1490941&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccFile.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccFile.java
 Sat Jun  8 10:09:03 2013
@@ -29,6 +29,32 @@ import org.apache.uima.ducc.transport.ev
 
 public class DuccFile {
        
+       public static Properties getUserSpecifiedProperties(IDuccWorkJob job) 
throws IOException {
+               String directory = 
job.getUserLogsDir()+job.getDuccId().getFriendly()+File.separator;
+               String name = DuccUiConstants.user_specified_properties;
+               Properties properties = null;
+               try {
+                       properties = DuccFile.getProperties(directory, name);
+               }
+               catch(Exception e) {
+                       // no worries
+               }
+               return properties;
+       }
+       
+       public static Properties getFileSpecifiedProperties(IDuccWorkJob job) 
throws IOException {
+               String directory = 
job.getUserLogsDir()+job.getDuccId().getFriendly()+File.separator;
+               String name = DuccUiConstants.file_specified_properties;
+               Properties properties = null;
+               try {
+                       properties = DuccFile.getProperties(directory, name);
+               }
+               catch(Exception e) {
+                       // no worries
+               }
+               return properties;
+       }
+       
        public static Properties getJobProperties(IDuccWorkJob job) throws 
IOException {
                String directory = 
job.getUserLogsDir()+job.getDuccId().getFriendly()+File.separator;
                String name = DuccUiConstants.job_specification_properties;

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java?rev=1490941&r1=1490940&r2=1490941&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java
 Sat Jun  8 10:09:03 2013
@@ -163,6 +163,13 @@ public class DuccHandler extends DuccAbs
        private String duccReservationInstanceMemoryUnits   = 
duccContext+"/reservation-instance-memory-units";
        private String duccReservationNumberOfInstances     = 
duccContext+"/reservation-number-of-instances";
        
+       protected String headProvider = "Provider";
+       
+       protected String providerUser = "user";
+       protected String providerFile = "file";
+       protected String providerSystem = "";
+       protected String providerUnknown = null;
+       
        public DuccHandler(DuccWebServer duccWebServer) {
                super.init(duccWebServer);
                initializeAuthenticator();
@@ -1335,8 +1342,16 @@ public class DuccHandler extends DuccAbs
        }
        
        private void putJobSpecEntry(Properties properties, String key, String 
value, StringBuffer sb, int counter) {
+               putJobSpecEntry(properties, providerUnknown, key, value, sb, 
counter);
+       }
+       
+       private void putJobSpecEntry(Properties properties, String provider, 
String key, String value, StringBuffer sb, int counter) {
                if(value != null) {
                        sb.append(trGet(counter));
+                       if(provider != null) {
+                               sb.append("<td>");
+                               sb.append(provider);
+                       }
                        sb.append("<td>");
                        sb.append(key);
                        sb.append("</td>");
@@ -1347,6 +1362,35 @@ public class DuccHandler extends DuccAbs
                }
        }
        
+       private boolean isProvided(Properties usProperties, Properties 
fsProperties) {
+               if(usProperties != null) {
+                       return true;
+               }
+               if(fsProperties != null) {
+                       return true;
+               }
+               return false;   
+       }
+       
+       private String getProvider(String key, Properties usProperties, 
Properties fsProperties) {
+               if(isProvided(usProperties, fsProperties)) {
+                       if(usProperties != null) {
+                               if(usProperties.containsKey(key)) {
+                                       return providerUser;
+                               }
+                       }
+                       if(fsProperties != null) {
+                               if(fsProperties.containsKey(key)) {
+                                       return providerFile;
+                               }
+                       }
+                       return providerSystem;
+               }
+               else {
+                       return providerUnknown;
+               }
+       }
+       
        private void handleDuccServletJobSpecificationData(String 
target,Request baseRequest,HttpServletRequest request,HttpServletResponse 
response) 
        throws IOException, ServletException
        {
@@ -1357,6 +1401,8 @@ public class DuccHandler extends DuccAbs
                DuccWorkJob job = getJob(jobNo);
                if(job != null) {
                        try {
+                               Properties usProperties = 
DuccFile.getUserSpecifiedProperties(job);
+                               Properties fsProperties = 
DuccFile.getFileSpecifiedProperties(job);
                                Properties properties = 
DuccFile.getJobProperties(job);
                                TreeMap<String,String> map = new 
TreeMap<String,String>();
                                Enumeration<?> enumeration = properties.keys();
@@ -1365,8 +1411,12 @@ public class DuccHandler extends DuccAbs
                                        map.put(key, key);
                                }
                                Iterator<String> iterator = 
map.keySet().iterator();
-                               sb.append("<table>");
+                               sb.append("<table id=\"specification_table\" 
class=\"sortable\">");
                                sb.append("<tr class=\"ducc-head\">");
+                               if(isProvided(usProperties, fsProperties)) {
+                                       sb.append("<th title=\"system provided 
if blank\">");
+                                       sb.append(headProvider);
+                               }
                                sb.append("<th>");
                                sb.append("Key");
                                sb.append("</th>");
@@ -1379,6 +1429,7 @@ public class DuccHandler extends DuccAbs
                                while(iterator.hasNext()) {
                                        String key = iterator.next();
                                        String value = 
properties.getProperty(key);
+                                       String provider = getProvider(key, 
usProperties, fsProperties);
                                        if(key.endsWith("classpath")) {
                                                value = formatClasspath(value);
                                                String show = "<div 
class=\"hidedata\"><input type=\"submit\" name=\"showcp\" value=\"Show\" 
id=\"showbutton"+i+"\"/></div>";
@@ -1386,7 +1437,7 @@ public class DuccHandler extends DuccAbs
                                                value = show+hide;
                                                i++;
                                        }
-                                       putJobSpecEntry(properties, key, value, 
sb, counter++);
+                                       putJobSpecEntry(properties, provider, 
key, value, sb, counter++);
                                }
                                sb.append("</table>");
                                sb.append("<br>");
@@ -1558,6 +1609,8 @@ public class DuccHandler extends DuccAbs
                DuccWorkJob managedReservation = 
getManagedReservation(reservationNo);
                if(managedReservation != null) {
                        try {
+                               Properties usProperties = 
DuccFile.getUserSpecifiedProperties(managedReservation);
+                               Properties fsProperties = 
DuccFile.getFileSpecifiedProperties(managedReservation);
                                Properties properties = 
DuccFile.getManagedReservationProperties(managedReservation);
                                TreeMap<String,String> map = new 
TreeMap<String,String>();
                                Enumeration<?> enumeration = properties.keys();
@@ -1566,8 +1619,12 @@ public class DuccHandler extends DuccAbs
                                        map.put(key, key);
                                }
                                Iterator<String> iterator = 
map.keySet().iterator();
-                               sb.append("<table>");
+                               sb.append("<table id=\"specification_table\" 
class=\"sortable\">");
                                sb.append("<tr class=\"ducc-head\">");
+                               if(isProvided(usProperties, fsProperties)) {
+                                       sb.append("<th title=\"system provided 
if blank\">");
+                                       sb.append(headProvider);
+                               }
                                sb.append("<th>");
                                sb.append("Key");
                                sb.append("</th>");
@@ -1587,7 +1644,8 @@ public class DuccHandler extends DuccAbs
                                                value = show+hide;
                                                i++;
                                        }
-                                       putJobSpecEntry(properties, key, value, 
sb, counter++);
+                                       String provider = getProvider(key, 
usProperties, fsProperties);
+                                       putJobSpecEntry(properties, provider, 
key, value, sb, counter++);
                                }
                                sb.append("</table>");
                                sb.append("<br>");

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js?rev=1490941&r1=1490940&r2=1490941&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js 
(original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js 
Sat Jun  8 10:09:03 2013
@@ -589,6 +589,7 @@ function ducc_load_job_specification_dat
                                hide_show();
                                data = "";
                                $("#loading_specification_area").html(data);
+                               
sorttable.makeSortable(document.getElementById('specification_table'));
                        }
                });
        }
@@ -628,6 +629,7 @@ function ducc_load_reservation_specifica
                        {
                                $("#specification_data_area").html(data);
                                hide_show();
+                               
sorttable.makeSortable(document.getElementById('specification_table'));
                        }
                });
        }


Reply via email to